Hue Bulbs detect bulb power on and run action

I currently have normal switches to power on / off my bulbs and i cannot change those with smart ones. I like to change bulb temperature based on time of the day and currently i have a stupid python scripts that pulls the HUE bridge every second and changes the light configuration.

This approach however is bad because if i then change it manually that script will revert the change immediately. So is there any smarter way to do this in home assistant? Any way to pull a device every second to see if its available? I have noticed that Home Assistant still lists the bulb as active for a while even if i switch the power off.

You’ll want to be careful of polling that often; the Hue Bridge has rate limiting in it, if you hit that limit it can start dropping your commands to the hub.

The way I solve this is use the default Hue integration into HA and update the bulbs if they change to their “on” state. If they’re powered on at the wall they usually update to the correct colour within 10 seconds or so.

Second thing you’ll want to do is make sure you’ve got the correct power on behaviour set for your bulbs, this is the behaviour of your bulb when it is turned on at the wall. If you set them to “Power loss recovery” they should come back on to the same colour and brightness they were powered off at.

1 Like

Thanks for your answer!!

Existing “bad” method is there since a couple of years now and works fine so probably its ok to poll every 5 seconds (i checked its not 1)

I tried automation below but its not triggered on physical switch on, am i doing something wrong?

  - platform: device
    type: turned_on
    device_id: ..
    entity_id: light.bagno
    domain: light

Works when triggered manually but doesnt do anything if i just turn the bulb “on” after being off 10 seconds. Maybe i need to wait more.

Recovery on Hue bridge is fine.

P.S. would conbee II make this any better?

It’s been a while since I wrote HA automations, I do most of my stuff in NodeRED now, but I’d consider using a state automation instead.

      platform: state
      entity_id: light.bagon
      to: 'on'

I’ve not used the device automation platform before, but it’s possible it’s asserting that the old state was off which won’t be the case for a Hue bulb powering on from unavailable (powered off at the wall).

Thank you, will try that, i guess the problem is that HUE doesnt update the state to unreachable quickly enough, maybe conbee is faster. I will check out NodeRED too if it makes complex workflows easier, my kubernetes deployment starts getting complex :slight_smile:

I just tested node red with Hue, its really cool and what i was looking for, lowering poll rate a bit can do exactly what i want. I now wonder why i need homeassistant :slight_smile: Thanks for the tip

Yes! First, welcome!

There’s a plugin for exactly the kind of behavior you’re looking for:

I recently went down the same path and have been happy with it so far. The manual control is buggy, but I’ve logged those bugs in the AL project and the maker is aware. The only thing I might add is that I switched to using a Zigbee USB stick (first Nortek, but switching it out for ConBee II), which is local push vs. polling and things are much snappier. Highly recommended!

Thanks for your tip! So Conbee II detects wall power on/off faster then Hue Bridge? I was able today to make this work using NodeRed which looks like its polling every 3 seconds, this alone is already a lot better than my previous attempt.

Yes, it’s instant since the bulbs are connected directly to the Conbee instead of a hub that is polled.

Wow thats cool, are those generic Zigbee or Philips Hue bulbs?

I’m using all Hue bulbs connected to Home Assistant through Zigbee directly.

Also of note is that previously I was using Hue motion sensors where the polling situation made it nearly unusable. Now that they’re going direct, they’re instant.

Thanks this is very helpful, will trash the Hue Bridge then and migrate to Conbee II seems a lot more fun :slight_smile:

1 Like

Did you manage to make it work? I’m having normal switches as well and I want to change brightness when powering on the bulb (through the switch).

The state “to: on” is not working for me. That only works when I turn the bulb from 0% brightness to any % above that. I’m using conbee II