johnlemonse / homebridge-telldus

36 stars 22 forks source link

ON / OFF state not synced between Telldus and homebridge #42

Open kennhardy opened 7 years ago

kennhardy commented 7 years ago

Not sure if homebridge or telldus live is supposed to share the state of a device? If so, then i am having difficulties getting it to work.

Heres the problem. If an device has the opposite state in HomeKit of what the actual physical switch / lamp has it does not work. Lets say the state of a lamp in ON i HomeKit. But the actual state of the physical switch is OFF because someone pushed an physical button to turn it off. In this case it still shows ON in HomeKit but OFF in Telldus Live.

Trying to turn ON the lamp using HomeKit will not work since the state already is on. So to actually turn on the lamp it has to be turned off, then on again in HomeKit. Everything else is working fine and the logs are not throwing anything related to this issue.

mifi commented 7 years ago

I noticed this too. It seems that when something is set to the state that it is already in, homekit will not do anything (no commands are sent). I don't know if there is any way we can alter this behaviour. Also I don't know if telldus supports switches that report state back. At least all my switches and dimmers are receive-only, thus it is impossible for telldus (and homekit) to know the actual true state in the device.

kennhardy commented 7 years ago

If you use the same house code and unit code for the receiver, switch and device in telldus live then it reports it. What I do when sexting up a lamp: Connect the receiver to the load (lamp in my case) Pair it with a switch (wall switch / dimmer in my case) Then create the unit in Telldus Live and scan transmitter. If you now turn on your device and the telldus live picks up the signal then all the three will have the same unit code and house code. By turning of the device with the switch, it will both turn off in TL and the switch.

mifi commented 7 years ago

Oh, I didn't know that. I assume it only works for tellstick that has receive capabilities, i have the ZNet lite, which only supports sending. If the correct status is reported to telldus live after you use the hardware switch, then also homekit should show the same status, because homebridge-telldus uses the telldus live api. And homekit queries all device statuses from TL each time it shows the buttons. Maybe you can try to use the api explorer and figure out whether it is showing the correct statuses too

kennhardy commented 7 years ago

Thank you! I will have a look at it then. Just need to familiarise myself with the code and all the .js scripts before starting troubleshooting. The devices get the correct status in TL whenever "manually" switching off an unit from a radio control / switch. Some devices seem to get the correct state from TL but it takes a very long time before it updates. And it also seem to only update the states for devices like switches / temperature (pull status for devices from TL) whenever i start up the HomeKit app on any IOS devices. Could it be possible to make HK pull the statuses in the background even when not opening the app? Like a refresh every 30 seconds or so? When opening the app I see it pulls the device state in the log: [2/7/2017, 1:39:26 PM] [Telldus Liv!e] [Huvudkontroll] Getting state for switch Huvudkontroll [off]

But as sais, this only happens once i open the app. So if I were to talk to siri and the device states are not synced I would have to turn it ON and OFF or vice versa depending on the sate being different.

mifi commented 7 years ago

You can also just use http://api.telldus.com/explore/index http://api.telldus.com/explore/device/info

and see if the state value changes when you change it with your switch.

it might be possible to do polling, but i can imagine that telldus doesn't like that lots of people keep polling hundreds of requests every minute.

I don't know what triggers a homekit sync other than opening homekit panel (slide up from the bottom of the screen), homekit app, and when entering home wifi.

I have a feeling that such things must be pushed to homekit. So that when a user switches a switch, we have to send an event to homebridge.

kennhardy commented 6 years ago

Would it be possible to add support for the local api of the Znet device in this branch? This would make the changes instant and the system would not need to speak directly to live.telldus servers.

mifi commented 6 years ago

Sure, we could build an API that can be used for both live and local. If we could find an npm module that supports both live and local through a switch, that would be best. See #53

mifi commented 6 years ago

I have now implemented local support in version 1.0 of homebridge-telldus

askusbloodfist commented 6 years ago

Thanks allot for this! I had 70% of my setup as Nexa Wall senders to recivers. And i been pretty irritated to see that it did not have status funktion on them. Had i known that, i propably would had gone for another type of setup.

But now th to you guys work i only need to change 2 places in to a Z-wave setup. CHEERS! Thanks for all your work!

I remade the setup to Lokal and then setup the Senders to work as kennhardy instrukted. Works like a sharm. Ty you both for the koding and everything! Now i dont need to hear the wife whine about the status being wrong on atleast most of the setup. 👍

ekhalil-SE commented 3 years ago

I have Homebridge and the Telldus plugin installed, I have an issue that when a status of a device is updated in Telldus this new status is not pushed to Homekit. To see the new status I need either to refresh the room where the device is or restart the app. Is this the way the plugin supposed to work? This way I can't create automations based on triggers that occur on Telldus! Changing from Telldus Live to local integration did not make any difference for me. Appreciate any help with this. Thank you,