Set Value Vbus

83 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 2.08 and I try to set the R13 value. I try with this script but not change the state. Can anyone help me please¿? Thank you

const vbus = require('resol-vbus');

const values = [{
valueId: 'Relais_Regler_R13_Handbetrieb',
valueIdHash: 1085278988,
valueIndex: null,
changedValue: 2,
currentValue: null,
}];

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, 0x00000000);
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`);
}

value.valueIndex = dgram.valueId;
}

// Resynchronize between lookup and get/set
dgram = await conn.getValueById(peerAddress, 0x00000000);
if (!dgram) {
throw new Error(`Unable to get changeset ID`);
}
}

const valuesToSet = values.filter(value => (value.valueIndex != null) && (value.changedValue != null));
if (valuesToSet.length > 0) {
for (const value of valuesToSet) {
dgram = await conn.setValueById(peerAddress, value.valueIndex, value.changedValue);
if (!dgram) {
throw new Error(`Unable to set value`);
}

value.changedValue = null;
value.currentValue = null;
}

// Resynchronize between get and set
dgram = await conn.getValueById(peerAddress, 0x00000000);
if (!dgram) {
throw new Error(`Unable to get changeset ID`);
}
}

const valuesToGet = values.filter(value => (value.valueIndex != null) && (value.currentValue == null));
if (valuesToGet.length > 0) {
for (const value of valuesToGet) {
dgram = await conn.getValueById(peerAddress, value.valueIndex);
if (!dgram) {
throw new Error(`Unable to get value`);
}

value.currentValue = dgram.value;
}
}

await conn.releaseBus(peerAddress);

await conn.disconnect();
}

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

Daniel Wippermann

unread,
Feb 4, 2024, 2:41:48 PM2/4/24
to resol...@googlegroups.com, Juan Guillén

Hi Juan,

have tried a different "changedValue" as well? "2" means "automatic mode", so there might not have been a change. You can either try "0" for "manually off" or "4" for "manually on".

Best regards,
    Daniel



Am 03.02.24 um 02:31 schrieb Juan Guillén:
--
You received this message because you are subscribed to the Google Groups "RESOL VBus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resol-vbus+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/resol-vbus/612d90fd-3dff-4253-abd8-a6492a6a7d03n%40googlegroups.com.

Juan Guillén Díaz

unread,
Feb 4, 2024, 2:46:06 PM2/4/24
to Daniel Wippermann, resol...@googlegroups.com
Thanks, it worked.
Reply all
Reply to author
Forward
0 new messages