yhaugom / com.telldus

Homey support for Telldus Z-wave devices
5 stars 14 forks source link

TZWP-102 Homey status does not update on external change #31

Closed bendikwa closed 3 years ago

bendikwa commented 3 years ago

Hi

(App version: 1.2.0) (Homey version: 5.0.0)

If I change the state of my TZWP-102's either by direct association or by pushing the button locally on the device, the status in homey does not change to reflect it.

I have tried to debug it myself and come up with a working fix, but I cant shake the feeling that I'm missing something obvious. Especially since it works if I disable the app, and include the plug with the default Homey app.

To me it looks like the the plug uses COMMAND_CLASS_SWITCH_BINARY for operating the device, but the report when it's state changes is sent on COMMAND_CLASS_BASIC:

node.CommandClass['COMMAND_CLASS_BASIC'].on('report') arguments: [
  { value: 3, name: 'BASIC_REPORT' },
  { 'Value (Raw)': <Buffer ff>, Value: 255 },
  null
]

With this as my understanding I got it working by adding a custom report listener in the device.js:

this.registerReportListener(
    'BASIC',
    'BASIC_REPORT',
    rawReport => {
        if (rawReport && rawReport.hasOwnProperty('Value')) {
            return this.setCapabilityValue('onoff', (rawReport.Value > 0));
        } else {
            return null;
        }
    },
);

So I submit this as my suggested fix, but, as I said, I feel like I'm missing something obvious.

-Bendik

yhaugom commented 3 years ago

Thank you for reporting. I think I know the reason. I had both BASIC and SWITCH_BINARY for another plug, and that caused problems earlier. I was also told that including both binary and basic on/off capability was not needed. So I thought I should remove it for TZWP-102 as well. I will re-add BASIC now, and release a new version.

Athom takes care of things behind the scenes, so no need to add custom report listener. It should be enough to add this line in device.js for TZWP-102 in ‘onNodeInit(): "this.registerCapability('onoff','BASIC’);"

I am sorry for the inconvenience.

New version coming very soon!

Yngve

yhaugom commented 3 years ago

This should be fixed in next version.

bendikwa commented 3 years ago

Yes, I can confirm that adding this.registerCapability('onoff', 'BASIC') also did the trick.

Thank you for the quick response.

-Bendik