Detect when light have been switched on from wall switch

Hi! I tried to google about this, but again found nothing. So, I have ZigBee module attached to my Raspberry PI and I have paired some Ikea Trådfri bulbs to my Home Assistant installation (zha platform) in order to reduce number of devices on my desk (Ikea gateway). What I found out, that if I power on my bulbs using power switch on the wall, NOT home assistant UI, Home Assistant never detects this. When I was using Ikea’s gateway, this was detected, however it took too long time for my use case.

So my question is that should this be detected? I understand that power off cannot be detected, but at least when I took a look of debug log I can see that when lights are powered on from power switch they seem to send signal which is detected by home assistant. But should home assistant react on this or not? If not, then perhaps this would be doable with simple scripting, no?

It may seem odd that I would like to detect power on from power switch, but in my use case it is extremely useful to know when lights are on. It does not matter if home assistant thinks light is on even if’s actually powered down from power switch. I am using customized fluxer to control color temperature and brightness of bulbs and for that to work, home assistant needs to know that bulbs are on, no matter how they have been powered on. Otherwise I may get dim orange light on the morning…

Thanks again a lot!


Ah nevermind, there is related issue reported on github (worked on previous versions). I assume this will be resolved over time.

Actually the bug I mentioned is about broken polling with zha platform and has nothing to do with lights pushing state to the home assistant. I spent this evening reading through source code and there is nothing there which would allow home assistant to detect when light has been switched on in zha platform.

But I was able to hack it together and got what I was after! I had to hack zigpy to pass through device announcement messages to zha platform and then hack zha platform to listen for these messages and turn on lights when detected. Now my setup works very well, color temperature and brightness of my bulbs are set based on time no matter if they have been switched on from UI or from power switch and it happens with zero delay.

Would put my code to github but I have little understanding of what I am doing so perhaps it’s best not to.

1 Like

would you mind sharing what you did by hack zigpy? I have the same issue and not yet found a solution.