i really want to connect our heatpump to homey. Therefor i start my own ‘development’ . what means i try to learn and copy from other existing apps/integrations.
Today i can connect the modbus IP interface, i can read differrent registers. also i add to different capabilities. ( picker to set mode & thermostat to adjust settings.) but from this point i miss the examples, knoledge how to proceed.
the picker i can set another mode but i do not know how to ensure the picker gets the active value from the modbusregister. when i open the device the picker doesn’t show the active setting. are there examples available to find out how to configure this?
The same question for the thermostat. for this i also am looking for code that belongs to this UI (capabilitylister ) i guess.
Can somebody help me to proceed ?
I have working all weekend to get it work and making some progress. however iám still struggling. i created an lister that registrate all changes. after using the picker i see the new vallue in the log. when i tried to write this new value to the right register it is not accepted. When using a modbus testtool i’am able to read and set the value by using FC 3 or FC 6.
I’am using code like below. do you have any idea how to solve this.
// Register capability listener for Operation_mode
this.registerCapabilityListener(‘Operation_mode’, async (value) => {
this.log(‘Changes to :’, value);
this.log(‘Modbus register to write to is:’, OPERATION_MODE_ADDRESS);
// Voeg een controle toe om te bevestigen dat de waarde geldig is
// Lees de huidige waarde van het holding register
try {
const currentRegister = await this._client.readHoldingRegisters(OPERATION_MODE_ADDRESS, 1);
const currentValue = currentRegister.response._body.valuesAsBuffer.readUInt16BE(0);
this.log(`Current value in register ${OPERATION_MODE_ADDRESS} is: ${currentValue}`);
} catch (error) {
this.error(`Error reading current value from operation mode register: ${error.message}`);
return;
}
// Voeg een vertraging van 2 seconden toe
await this.delay(2000);
this.log('delay2000ms');
// Log de waarde en het adres die worden geschreven
this.log(`Writing value ${value} to operation mode register at address ${OPERATION_MODE_ADDRESS}`);
// Schrijf de nieuwe waarde naar het Modbus-register
try {
const result = await this._client.writeSingleRegister(OPERATION_MODE_ADDRESS, value);
this.log(`Written value ${value} to operation mode register ${OPERATION_MODE_ADDRESS}`, result);
} catch (error) {
this.error(`Error writing to operation mode register: ${error.message}`);
}
});