glenndehaan / ikea-tradfri-coap-docs

How can you communicate to your ikea tradfri gateway/hub through coap-client
MIT License
189 stars 21 forks source link

Notification when status of light changes #17

Open sanderisbestok opened 4 years ago

sanderisbestok commented 4 years ago

Hi,

Is there a way to get "notified" when the status (scene, on/of, dimmer) of a lightbulb change. Or is it necessary to constantly ask the endpoint what the status is?

Want to use this on my smart mirror to display the light status, I have seen some apps where it updates almost immediately after you press the hardware IKEA button.

glenndehaan commented 4 years ago

Hi @sanderisbestok,

As far as I know the CoAP protocol isn't a protocol for providing a realtime connection. What I mean by that is that when you do a request a connection gets setup between you and the gateway, a message is send to the gateway and after that a response is send back over the same connection. At this point the connection will close since that completes the call.

When looking at de decompiled app from IKEA I can't find any reference to a sort of 'live' connection between the app and the gateway. No it is possible i'm missing something since the decompiling process isn't great and searching for code is sometimes impossible.

I think that polling or pinging the gateway is at this moment the best sollution. Of course if anyone finds something useful that could implement a way of getting real time data i'm always up for suggestions.

sanderisbestok commented 4 years ago

Hi @glenndehaan,

Thanks, I will try to decompile the app I used to see if anything interesting happens over there. Is there a maximum of pings you can do to the tradfri device in a certain amount of time?

glenndehaan commented 4 years ago

I don't believe there is any sort of request limit or at least I have not run into one yet.