Philips Hue bulb automation delayed

Good evening everyone.

I have a Philips LCT010 set up via Zigbee Home Automation and connected via a Homeassistant Sky Connect. The automation that I have set up looks like this:

alias: Bedtime
description: ""
trigger:
  - platform: state
    entity_id:
      - light.signify_netherlands_b_v_lct010_light_3
    for:
      hours: 0
      minutes: 0
      seconds: 0
    attribute: brightness
condition:
  - condition: time
    after: "19:00:00"
    before: "06:30:00"
action:
  - type: turn_on
    device_id: cd90c8bcd682007c65060be37f66e306
    entity_id: d7d87a7cdb2573ca97d30007be0d9c38
    domain: light
    brightness_pct: 20
mode: single

Which used to set the light to 20% within a couple of seconds of the light switch being turned off and on. This is to let my child know that it’s bedtime and if they wake up in the middle of the night and try to turn their light on and it goes straight off, then it’s still bedtime.

However if the bulb is power cycled with the light switch a couple of times (which they very quickly cottoned onto) the light stays on 100% brightness and doesnt go back to 20% for a while.

But it is appearing in HA as being at 20% even though it’s not.

Same happens if I set the startup to 20 instead of 255 like it’s default is set as.

The light dims down to 20% when I manually run the automation. But it makes the automation pointless if I have to manually run it.

Is there something I’m missing?

The trigger doesn’t look right - there doesn’t seem to be a state value. I would expect something like…

platform: state
entity_id:
  - light.signify_netherlands_b_v_lct010_light_3
to: "on"

You don’t need the brightness attribute unless a particular value is part of the trigger, and you don’t need the “for” bit if you want the automation to trigger immediately. (If you’re editing in the UI these fields are optional).

In the action part, it’s good practice to use entities if you can, rather than device ids, which carry a lot of disadvantages.

Why and how to avoid device_ids in automations and scripts

Welcome to the forum, by the way. :smile:

Thanks. Long time lurker and usually I can find what I’m looking for by searching or by messing around. But this is a weird one because it works… Just not quickly. Haha.

I have been using the visual editor and copied the code from the yaml as I know it’s easier for other people to diagnose.

I changed it to:

alias: Bedtime
description: ""
trigger:
  - platform: state
    entity_id:
      - light.signify_netherlands_b_v_lct010_light_3
    attribute: brightness
condition:
  - condition: time
    after: "19:00:00"
    before: "06:30:00"
action:
  - type: turn_on
    device_id: cd90c8bcd682007c65060be37f66e306
    entity_id: d7d87a7cdb2573ca97d30007be0d9c38
    domain: light
    brightness_pct: 20
mode: single

With the same result. Turning the light switch off and on twice, reverts the light to 100% for an unset amount of time.

Trying to change the action from device_id to entity_id is proving to be out of my depth :joy:

I’d be guessing it’s something to do with Zigbee Home Automation picking the light up as being on 20% when it’s not, that’s the issue? As when I try to turn the brightness up or down after they’ve pressed the light switch 2 times, it goes instantly to “on” at 20%. Even if I try and turn the light off in HA aswell.

Sorry, I’m being particularly dense. Now that I read your post properly, I see that power is being cut to the light completely - and presumably the start up level is set to 100%. Ignore me, I’m an idiot.

Something like this would set the light to 20% and set the start up level to 50 (20% of 254).

alias: Bedtime
description: ""
trigger:
  - platform: time
    at: "19:00:00"
condition: []
action:
  - service: light.turn_on
    metadata: {}
    data:
      brightness_pct: 20
    target:
      entity_id: light.hallway_1
  - device_id: 32210231fb1d3b3e1f4e895e7eb1a543
    domain: number
    entity_id: b96eee911b0664b924d8e65fa8d46b24
    type: set_value
    value: 50
mode: single

In the UI this is “Set value for Start-up current level”

Apologies. This went on the back burner cos they forgot about it. And so did I :joy:

They’ve just realized it again.

So the automation only lasts 2 power cycles.

So this is how it currently is:

alias: Evelyn bedtime
description: ""
trigger:
  - platform: state
    entity_id:
      - light.evelyn
    attribute: brightness
condition:
  - condition: time
    after: "19:00:00"
    before: "06:30:00"
action:
  - type: turn_on
    device_id: cd90c8bcd682007c65060be37f66e306
    entity_id: d7d87a7cdb2573ca97d30007be0d9c38
    domain: light
    brightness_pct: 5
mode: single

If they turn the light off at the switch and turn it back on quickly, twice. On the third time it ignores startup value and the automation and stays on at 100% until it eventually picks up that the brightness has changed and appears in HA as being on 5%.

But if you change the brightness at all after the third power cycle, it picks the light up brightness variable changing and sets it to 5% as it should.

I use zigbee home automation and not zigbee2mqtt due to setting up initially with ZHA and not Z2M. Could it be an issue with ZHA not syncing with the bulb or something?

My final idea is to get a couple of hard wired smart light switches and disable them in the automation, but that seems like overkill and I’d rather not do it.