node-tradfri-client
node-tradfri-client copied to clipboard
Document the possibility to force an update of the "alive" state
See: https://github.com/AlCalzone/node-tradfri-client/issues/106#issuecomment-423179794
- GET coaps://IP_ADDRESS:5684/15001/BULB_DEVICE_ID and extract warmth value from reply
- PUT warmth - 1 (1 if warmth == 0) to the above URL
- wait 1 second
- PUT warmth (original value) to the above URL
- wait 1 second
- loop 5 times to point 2
I don't know if there's better method, but this work fine. I used warmth because it doesn't noticeably influence the bulb state if it is powered on. Changing brightness would turn on the bulb, if if is powered on and in OFF state on the gateway. In my tests, the true alive status was determined after 6 seconds. The loop runs to 10 seconds to make sure. I also tried just changing the warmth once, but then it would take full 10 seconds to get the true status. My python implementation is here https://github.com/nykfank/ikea_tradfri_alive/blob/master/ikea_tradfri_alive.py
Did you check the gateway updates (observeDevice) for turned-off bulbs? Do those come and include the correct color temperature (the one you just set)? If yes, this could be a way to bail out of the check loop early if the bulb is alive. Edit: I see you're not using this lib in your test. Might be something worth to check out.
Yes, that could be an interesting idea! At what endpoint can I get the gateway updates? 15011/15012? I would like to use your library, but couldn't get node/npm installed on my SheevaPlug yet.
Basically you have set the observe option for the specific endpoint you are interested in, eg devices/deviceID
Is it really needed to change a value for a device to receive an update? The warmth, for instance won't work with a non-white spectrum light. And from what I understood the gateway will also respond with a new alive value after it receives an update for a bulb in which no properties have been changed.
Am I correct in assuming that if a lightOperation was sent to a device that contains no changes, that this update is not sent? And if so, maybe implement a force update option?
Is it really needed to change a value for a device to receive an update? The warmth, for instance won't work with a non-white spectrum light.
You can also use the brightness for no-spectrum lights (with the downside that turned-off bulbs may be turned on) or color/hex/sat for RGB lights. Currently, the way this lib is designed, the bare minimum of data is transmitted. This means that a no-change operation won't send anything. I'll have to add a way to force the command to be sent.
I'll have to add a way to force the command to be sent.
That would be awesome! :)
You were right, setting the brightness for no-spectrum lights turns them on, so that is not an option. I then tried it by changing the transitionTime ( using operateLigh() ) and all though the command (seems) tor work ok, it does not trigger any callbacks.
So I guess it is safe to say that at the moment for no-spectrum lights there is no way to determine the "alive" state by forcing an update. ( unless switching the light on when it is off is not a problem of course :) )