Hue light status stopped working recently

I have an automation set to switch on a floor lamp to a particular brightness when the front door is unlocked at night, which has worked fine for months, but suddenly stopped working a few days ago (may have aligned with one of the 2024.4.x releases).

The automation checks the light is off first, so it doesn’t suddenly crank it up bright if someone’s already home and has it down low.

Traces show the automation stops when it checks to see if the light is off.

Should I be checking the light status a different way? Or has some Hue integration bug appeared? I built the automation using the editor, but here’s the YAML:

alias: Lamp on when getting home
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.front_door_lock_status
    from: Locked
    to: Unlocked
condition:
  - condition: sun
    before: sunrise
    after: sunset
  - condition: device
    type: is_off
    device_id: 0f764e22743e62c42f80d00cc5af6c2b
    entity_id: de358d849f37959e3153c998f90d2a01
    domain: light
action:
  - type: turn_on
    device_id: 0f764e22743e62c42f80d00cc5af6c2b
    entity_id: de358d849f37959e3153c998f90d2a01
    domain: light
    brightness_pct: 75
mode: single

It looks as if it ought to work. Have you tried it using entity states rather than device ids?

1 Like

Agreeing with @Stiltjack said… I’m willing to bet one of the device ids changed from the integration and that’s what is causing it. Changing to entity ids will prevent this from happening when device ids change (and they do sometimes change :frowning:).

Thanks everyone. I tried rewriting the automation with entity states instead of device states and it does now seem to work. Weirdly, I checked and the device/entity IDs hadn’t actually changed, so who knows what was actually going wrong. Still better to be using the entity names now.

For anyone looking for what a working version of the above YAML, here it is. I was tripped up by entity brightness being an integer (0-255) instead of a percentage like with the device version. Not sure why they’re inconsistent like that.

alias: Lamp on when getting home
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.front_door_lock_status
    from: Locked
    to: Unlocked
condition:
  - condition: sun
    before: sunrise
    after: sunset
  - condition: state
    entity_id: light.floor_lamp
    state: "off"
action:
  - service: light.turn_on
    metadata: {}
    data:
      brightness: 191
    target:
      entity_id: light.floor_lamp
mode: single

1 Like