How to check a device still online in the ZigBee network

when the power goes out, is there a clever way to tell Homey to give a command to all lights ikea equal to the last status in memory on homey?
so if I shorten that the current returns I do it by hand.
if then there was a way to understand when homey comes back online giving it automatically

I don’t think there’s a way to do that. Some lights (I think the Hue’s) can be configured to remember their last status, perhaps the IKEA lights can do the same?

Yes they do.

1 Like

The Tradfri bulbs do that by default, either when powered off by remote (and still connected to 230v) or by switching them off completely with a switch or plug (no 230v).

but only if you use the ikea hub. if you connect directly to Homey without ikea hub doesn’t work.
when the power go off and on (eg blackout) the homey see the light ikea off, but the light are on.
I use the app:

IKEA Trådfri

by Athom B.V. v1.4.2 - 13.09.19

Let me dig this topic out - I’m also interested in tracking the state of zigbee bulbs (tradfri, hue, osram) which can be disconnected from electricity. I have two use cases:

  • Possibility to check if I have turned the lights off when I left home
  • Creating a flow with “bulb has been turned on” event as a trigger

Unfortunately it seems like neither case can be right now achieved using Homey :frowning: Even when I periodically send “dim” command (or whatever else) - no matter if I connect bulbs to Homey directly or using Hue bridge, Homey never mark them as unavailable.

This is what happens:

  • Bulbs connected to Homey directly: when I try to dim the disconnected bulb from Homey UI, it shows red error message, the new state is not remembered, but the device is still marked as available. When I dim the bulb from the flow, the new state is not remembered, but the device is still marked as available.
  • Bulbs connected to Hue bridge: when I try to dim the disconnected bulb from Homey or from the flow, it doesn’t even show the red error message, the new state is remembered, everything behaves as if the change has actually happened! What really makes me mad is the fact, that the Hue bridge CAN DETECT offline devices within seconds - I don’t know how it does it, but when only I disconnect the device, the Hue app displays “unavailable” text next to this light. Maybe the Hue bridge periodically sends some kind of ping to bulb?

One workaround for bulbs connected to Homey directly is to periodically try do dim it by 1% - ex. from 100% to 99% - and then check if the state is remembered. However it requires a lot of flow cards, just to check one single bulb, I don’t know how could I parametrize it - and the result can only be stored inside variable, the UI is still incorrect.

If anybody finds the solution, I’m very interested in it!

In Domoticz i had implemented an enhanced Dzvents script that would get a JSON from the HUE bridge every minute. in this JSON the state of each lamp is described, included if they were available (reachable). The results would be stored in a table and if a lamp was not “seen” every minutes for 5 minutes, the lamp was turned off.
I’m sure the same can be done on Homey, it is just that my java script knowledge is non-existent.

The original dzVents script can be found here: (it is the third script, which does not have any dependencies https://www.domoticz.com/wiki/Simple_script_to_update_Philips_Hue_status

In short the url to get the complete light status overviewcis
http:///api/0yBVz2bSgFmPfsMieO4NecDuIfwJPERlfOA8CZO-N/lights
where you have to put your own IP address for the bridge (so that has to become static) and your HUE-bridge key (token).
See https://www.sitebase.be/generate-phillips-hue-api-token/ to get the token.

Next the returned JSON has to be transformed into a table.
and for each lamp in the table the ‘state’ has to be checked: if the state.reachable == false while homey/HUE==ON it needs to be turned off, to sync the HUE state to the IRL state.
In the script the “state.on” is also checked and synced. (in case the lights are switched outside Domoticz. Not sure if this is also needed for Homey?

Quoted from the the dzVents script (which is based on/built on LUA)

           for i, light in pairs(lights) do
                if (domoticz.devices( light.name ) ~= nil) then
                    local device = domoticz.devices( light.name )
                    if( light.state.on == true and device.state == 'Off') then
                        device.switchOn()
                    elseif( light.state.on == false and device.state == 'On') then
                        device.switchOff()
                    elseif( light.state.reachable == false and device.state == 'On') then
                        previousData.add( light.name )

Then the script has some extra bits with a persistent table, so that only when a light is not reachable for 5 consecutieve minutes, it will be turned off. To prevent a lamp is switched of in the first minute when a connection fails. The on/off syncing was done in the first minute.

I hope one of you could take the above to create some script? (fingers crossed). Alternatively

For hue, this will help you:

http://yourhuebridgeip/debug/clip.html
In the window you see, post to /API:
{“devicetype”: “my_playground#blabla”}
Do this after you pushed the blue button on the bridge.

This way you will get the username you need to perform these actions:

https://developers.meethue.com/develop/hue-api/lights-api/

(Make sure to create a developers account to get in that api docs)

Then, make sure you can with with the better logic app (in combination with the Http flow cards). To get the light reachable status.

In Http flow cards, use under “then” the get JSON action.

1 Like

@James_Wyatt Thank you for your contribution, i think this is a very good method in detecting offline Hue devices.

I’m trying to implement your idea but HTTP request flow cards gives an error: Value not found.

Almost there… maybe you have a suggestion what could be wrong?

Did you use the correct URL?

Did you use the right lamp? Are you able to access the clip API debugger?

And thanks for the compliment :slight_smile:

In your example i see the URL starts with HTTP instead of HTTPS.

Changed that to make it work. What concerns me, is that the solution is less secure now; my API key is visible with a packetsniffer.

You don’t trust your own network?

I don’t trust any network. Offtopic in this thread, but how can I trust devices in my network running on closed source software? Some of them have an old OS which isn’t patched anymore. How can I trust my neighborhood; they can capture the wireless traffic between my Homey and Hue?

What’s against more security, no mather if it’s local or public data traffic.

There’s nothing against more security, but local devices typically can’t support HTTPS when you have to access them through their IP-address.

If you want to access your Homey locally over HTTPS, you need to allow DNS rebinding in your local network, with which you open up your network for rebinding attacks. Otherwise, you can only access Homey through the cloud or over plain HTTP (and since your neighbours have cracked your WiFi that isn’t ideal either).

You’re right when it comes to DNS and signed certificates. I’m talking about selfsigned certificates and IP address usage to my Philips Hue. Except a man-in-the-middle attack, a selfsigned certificate encrypts the traffic between the two hosts. By capturing the WiFi traffic -and finding the WPA2 key- they still don’t have my Hue API key.

An extra security is to store the hue-host certificate as trusted to prevent M-i-t-M, but I think this is more related to Homey Core then this app.

Unless you allow DNS rebinding, local traffic to your Homey will also be unencrypted and capturing its WiFi traffic would probably pose a much bigger risk to your home.

To get back more on topic: I understand the usefulness of detecting offline nodes, but isn’t it bad if Zigbee bulbs go off power all the time? Won’t that mess up your mesh? Maybe most devices will find another route, but it sure won’t do response times any good when routers are disappearing and reappearing unexpectedly.

I think you should avoid powering off the devices as much as possible. Found more info (Zigbee V3) here: What Is Zigbee Wireless Mesh Networking? | Digi International

Off course it is better for the mesh to switch off the lights via Homey/HUE or programmable buttons in the home. In my case i replaced (almost) all my bulbs (25+) with HUE bulbs/Tadfri bulbs/Osram plugs/Hue plugs/zwave plugs. (i prefer to include Hue hub to have a dedicated app / keep integration with Apple home.
But we will keep using the physical switches as well, thus the need fro me to create a tool to sync HUE light state based on reachability.
I minimize this ‘risk’ of people turning off the lights physically by using flow cards to auto turn of lights based on time of day/ light level / duration being on / movements / some ip address presence (work laptop for office, ps4 for game room). And i’m thinking to add mb’s downloaded via de router as well. (if that is zero, everybody must certainly be asleep?)

Big thank you for this. I used it as a base to create a Homeyscript to copy what I did earlier in dzVents on Domoticz. Both to get the status of the ligths and also to turn of the lights if they are contiuously unreachable for set time period.
I posted and discussed the code here: topic