ebaauw / homebridge-hue

Homebridge plugin for Philips Hue
Apache License 2.0
898 stars 91 forks source link

Sometimes individual lights in groups (Apple home) won't turn on, however the light(s) is/are connected in Phoscon #1017

Closed ChristianPorsche closed 3 years ago

ChristianPorsche commented 3 years ago

Issue

I created within Apple Home a group of 8 lights. However, 1 out of 5 times, 1 or 2 lights won't turn on if I turn them on or off within the home app. I diagnosed myself where the problem is and I could conclude that it is somewhere between the connection of homekit and phoscon, due to the fact that I can't turn on the light within homekit but within 10 seconds of trying in phoscon, I could turn the light on. After that, the light works for a day or a few hours within homekit.

Log Messages

If logs are needed, I will provide it.

Debug Files

If debug files are needed, I will provide it. I won't provide it now because I need to restart homebridge and this causes for different colors and settings I need to reselect after reboot.

ebaauw commented 3 years ago

Phoscon is just web app talking to the deCONZ gateway over the API, just like Homebridge Hue. It has nothing to do with exposing devices to HomeKit. See https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/deCONZ-for-Dummies for details.

Zigbee doesn't maintain connections; each message is routed separately. The gateway marks a device as unreachable, if it got no reply or ACK for a last couple of messages, but that doesn't say anything about whether the device is currently reachable. An individual message could be lost due to interference.

Make sure to turn on error loggin in deCONZ GUI and check the deCONZ log for errors related to interference, see https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Zigbee-Error-Codes-in-the-Log.

Using HomeKit groups results in different Zigbee messages for the different devices, effectively causing a storm on the Zigbee network. Homebridge Hue should throttle the API calls to the deCONZ gateway, to prevent the Zigbee network from congestion.

Check the Homebridge log for errors returned by deCONZ. Homebridge Hue logs each interaction with HomeKit, use that to check whether HomeKit is indeed sending updates for each light in the HomeKit group. Turn on Homebridge debug mode, to have Homebridge Hue log the interaction with the deCONZ gateway as well.

What brand and types of lights are failing? Are you only turning the group on or off, or are you also changing the brightness? Note that not all Zigbee lights are created equal. I think I've implemented workarounds for the most common firmware bugs (e.g. for IKEA, GLEDOPTO), but it's hard to keep track of all the new lights.

ChristianPorsche commented 3 years ago

@ebaauw thanks for your answer.

The link I made between phoscon and homekit is indeed wrong, however, for my problem it doesn't really change my diagnose.

When I turn 8 Ikea GU10 on with my iPad within homekit, 7 turn on. However, if I go to phoscon and change the brightness (because within phoscon I also see the light as turned on) ALL 8 lights will go to the brightness I just set within phoscon. If I turn the group of with my iPad, everything is turned off.

Maybe, for the first diagnose what the problem could cause, is there anything I could add to the code to turn of adaptive lightning? To me, it looks like it causes a load of log and my home hub get's a little bit glitchy. Yes, I know selecting another color should do it, but somehow, something keeps selecting adaptive lightning after a while.

Edit: As we speak, I have the problem again. I try to turn the 8 lights on but 7 go on. I see in deConz conbee on my rp4 a red light flashing next to the bulb. Anything I could do to get information regarding that red circle?

Edit2: I try to control lights with the 'groups' light, so I don't need to group them within homekit, however, I get all my Ikea remotes within homekit as lights. How could I disable this, I can nowhere find any information?

ebaauw commented 3 years ago

my home hub get's a little bit glitchy.

The Home hub is hardly involved in adaptive lighting. It is used only once a day, to update the schedule.

I see in deConz conbee on my rp4 a red light flashing next to the bulb. Anything I could do to get information regarding that red circle?

Read the deCONZ for Dummies I linked above: it indicates that the deCONZ gateway got no response from the light. Did you check the deCONZ log for Zigbee errors?

I get all my Ikea remotes within homekit as lights. How could I disable this, I can nowhere find any information?

Unset groups and whitelist the groups you want to expose, or blacklist the groups you don't want to expose. See https://github.com/ebaauw/homebridge-hue/wiki/Resource-Links.

ChristianPorsche commented 3 years ago

I changed in the last two hours my home setup quite much. All individual lights which are combined in the home app to a group are removed and I only use 'groups' from deconz/phoscon. The stability is much better and the last hour of testing I had never the bug of a single light within a group not turning on. I guess 8 calls from homekit to homebridge was too much, but one call from homekit to homebridge and then the call from homebridge to deconz goes better. I must say, the lights turn on even nicer. Not 1 at a time, like on-on-on-on etc., but the whole group turns exactly the same time on.

Thanks for the explanation of blacklisting 'Ikea remotes'. It is though code for me, so I will try my best.

Back to the adaptive lightning, it is indeed true that ones everything is setup, my iPad (home hub) won't glitch anymore with, because I turn my lights on with my iPhone, but the responsiveness decreases dramatically. If I try to turn it to a 'white based' color, it simply won't take it. It keeps in the adaptive lightning and the only thing I could do is to turn the light off and wait for a few minutes and select the color before even turning on or restart homebridge. So I simply decided to not use adaptive lightning anymore. Sad...because it was the number one reason to buy a conbee stick including this plugin. Follow up question (if you use adaptive lightning, if not, ignore this question), do you manually turn on your lights and adjust the brightness or created scene's based on time or lux input so the system can take his time to change the color of the bulbs?

ebaauw commented 3 years ago

Adaptive lighting adjusts the colour temperature based on the light's brightness and the time of day. Basically HomeKit provides a big lookup table ("curve") of fixed time points mapped to colour temperature values for full brightness, and the light bulb is supposed to compute (extrapolate) and set the precise colour temperature for the current time and actual brightness. This only interaction with HomeKit is enabling/disabling adaptive lighting, turning the light on or off, setting the brightness, and, once per day, refresh the lookup table. The initial curve is provided by the iPhone or iPad used to enable adaptive lighting; the home hub only plays a role in the daily update of the curve. And, I suppose, when you enable adaptive lighting from a HomeKit automation, which runs on the home hub.

As Zigbee lights don't implement this in firmware, Homebridge Hue handles this logic. If you expose (Hue) lights natively by the Hue bridge, this logic is handled by the Hue bridge.

If you turn a light on, or change its brightness, Homebridge Hue computes the ct value, and makes a combined API call to deCONZ (or the Hue bridge) setting on, bri, and ct. To deCONZ it seems like the user just sets bri and ct at the same time. Next, Homebridge Hue informs HomeKit of the updated colour temperature. Both Zigbee and HomeKit treat colour temperature like a stepchild. If the light also supports colour, Homebridge Hue needs to set Hue and Saturation to the matching colour temperature, as HomeKit doesn't read the Color Temperature value; it's used only for setting the colour temperature (manually, when adaptive lighting is disabled). Note that Home and other HomeKit apps obfuscate what characteristics they use: the might actually set Hue and Saturation, even when you interact with the Temperature wheel. Check the Homebridge log to be sure.

Homebridge Hue disables adaptive lighting automatically, when the light colour (xy) has been set, from whatever API client, or even from a Zigbee controller. Contrary to the Hue bridge, Homebridge Hue does not disable adaptive lighting when the colour temperature (ct) has been set.

I'm not a big fan of adaptive lighting: it sets the lights too cold for my taste. Hence the brightnessAdjustment setting.

I hardly ever control my lights manually. I think the idea of home automation should be "set and forget" and let the home control itself. I've implemented this using automations in deCONZ, that recall Zigbee scenes, depending on room occupancy, time of day, light level, and activity (like sleeping or watching TV). I use Hue motion sensors for occupancy and light level. My Zigbee scenes set both brightness and colour temperature (they are from way before adaptive lighting) - that's the reason behind not disabling adaptive lighting when setting the colour temperature. I still haven't figured out the best way to change my automations, with the introduction of adaptive lighting. So much to do, so little time...