Reading the sensor and relay of DeltaSol MX

57 views
Skip to first unread message

Juan Guillén

unread,
Feb 4, 2024, 7:26:44 AM2/4/24
to RESOL VBus
Good morning, I have a DeltaSol MX and I try reading the specific sensor. I try do it with:
const vbus = require('../resol-vbus');

const values = [{
valueId: 'Sensor_Regler_S3',
valueIdHash: 474103359,
valueIndex: null,
// changedValue: 2,
currentValue: null,
}];
console.log('Reading the temperature sensor 3.');

function hex(value, digits) {
return `0x${value.toString(16).padStart(digits, '0').toUpperCase()}`;
}

async function main() {
const conn = new vbus.TcpConnection({
host: '192.168.1.174',
password: 'vbus',
});

await conn.connect();



conn.on('datagram', dgram => {
const bytes = Array.from(dgram.toLiveBuffer()).map(b => hex(b, 2)).join(' ');
console.log(`- \`${bytes}\``);
console.log(` - destination address = \`${hex(dgram.destinationAddress, 4)}\``);
console.log(` - source address = \`${hex(dgram.sourceAddress, 4)}\``);
console.log(` - command = \`${hex(dgram.command, 4)}\``);
console.log(` - 16-bit parameter = \`${hex(dgram.valueId, 4)}\``);
console.log(` - 32-bit parameter = \`${hex(dgram.value, 8)}\``);
});

let dgram = await conn.waitForFreeBus();
if (!dgram) {
throw new Error(`No bus offer received`);
}

const peerAddress = dgram.sourceAddress;

// console.log(`PeerAddress = 0x${hex(peerAddress, 4)}`);

dgram = await conn.getValueById(peerAddress, 0X0861);
if (!dgram) {
throw new Error(`Unable to get changeset ID`);
}

//console.log(`Changeset ID = ${hex(dgram.value, 8)}`);

const valuesToLookup = values.filter(value => (value.valueIdHash != null) && (value.valueIndex == null));
if (valuesToLookup.length > 0) {
for (const value of valuesToLookup) {
dgram = await conn.getValueIdByIdHash(peerAddress, value.valueIdHash);
if (!dgram) {
throw new Error(`Unable to lookup value ID hash`);
}
console.log('THE VALUE->');
console.log(dgram);
value.valueIndex = dgram.valueId;
}

// Resynchronize between lookup and get/set
dgram = await conn.getValueById(peerAddress, valueIndex);
if (!dgram) {
throw new Error(`Unable to get changeset ID`);
}
console.log('TRY THE VALUE -> ');
console.log(dgram.getValue());
}

await conn.releaseBus(peerAddress);

await conn.disconnect();
}

main().then(null, err => {
console.error(err);
process.exit(1);
});

The result is:
Datagram {
  timestamp: 2024-02-04T08:24:01.333Z,
  channel: 0,
  destinationAddress: 32,
  sourceAddress: 32273,
  minorVersion: 0,
  command: 4353,
  valueId: 0,
  value: 474103359
}

I can´t see how I get the value. 

Thank you for your help.
Reply all
Reply to author
Forward
0 new messages