Long, 12 hour, Automation Failing

Yeah that’s my thought too, it’s either being turned off by something else, or there is a problem with the device. Although it appears in the logbook entries, there is no sign in the automation itself that it has done anything other than turn the light on.

Thanks !

It’s a Hue bulb

I added it via Deconz

It doesnt cause any errors elsewhere

And that’s the only automation it’s in. It’s only present in HA.

Also the fact that the turn off action is part of the trace confirms it is this automation doing it? Right?

Do not manually trigger automations to test them when the automation employs the trigger variable in its condition or action. Why? Because the trigger variable is undefined when the automation is triggered manually as opposed to when it’s triggered by one of its triggers.

This is explained here: Testing your automation

tl;dr
Example is fine. Failure is due to invalid testing technique.

Ahh ok that makes sense for that idea

But that implementation avoids the fact this doesn’t work as it should


alias: Front Door Sunset/Sunrise
  description: ''
  trigger:
  - platform: sun
    event: sunset
    offset: -01:00
    id: sunset
  - platform: time
    at: '23:30:00'
    id: time
  - platform: sun
    event: sunrise
    offset: -02:00
    id: sunrise

  condition: []

  action:
  - choose:
    - conditions:
      - condition: trigger
        id: sunset
      sequence:
      - type: turn_on
        device_id: 03419912808df6849d866075b5de8421
        entity_id: light.outdoor_front
        domain: light
        brightness_pct: 100

    - conditions:
      - condition: trigger
        id: time
      sequence:
      - type: turn_on
        device_id: 03419912808df6849d866075b5de8421
        entity_id: light.outdoor_front
        domain: light
        brightness_pct: 30

    - conditions:
      - condition: trigger
        id: sunrise
      sequence:
      - type: turn_off
        device_id: 03419912808df6849d866075b5de8421
        entity_id: light.outdoor_front
        domain: light`Preformatted text`

I didn’t know about that. When was this implemented?

I’m in the “make this three separate automations” camp. Separate automations are much easier to maintain - as evidenced by this thread. Lol

1 Like

I have separated it now.

For one, it will confirm it works that way to exclude other errors.

Am a bit disillusioned with HA not being able to do this simple automation though. I wonder if I should try NodeRed but cba at the moment.

1 Like

The example you are referring to isn’t the one I suggested. However, it will fail to work if you trigger it manually because it also relies on the trigger variable.

The example I posted is simple.

Did you review the documentation link I posted? It explains how to test an automation (and how not to test it).

That’s not necessarily true. For example, the suggested automation I posted above is easier to maintain, than three separate ones, because all three triggers are consolidated in one place. Plus it’s shorter (less code to manage).

The sole complication is that the topic’s author appears to be unfamiliar with Home Assistant’s automations. As a consequence, a bad test procedure was employed to produce a faulty result.

Your help and advice is honestly well appreciated

And I do understand what you are saying about testing

I haven’t actually tried the automation you suggested to be fair; and it does seem ingenious but it seems more of a hack to skirt around the fact that the automation with Trigger IDs and the Choose Option in the Actions isn’t working as intended.

I mean my point is, I am a fairly basic person in terms of coding.

I could create and understand the Trigger ID/Choose actions via the visual editor.

But I would never come up with what you suggested, and I would really like to avoid filling up my HA automations with scripts that I will struggle to maintain myself.

I would really like to understand why the Trigger ID/Choose method is turning the light on and immediately off. Otherwise, for my long term benefit separate automations are preferable for my personal use as I will be better able to maintain, understand and modify them in the future.

Make sure you remove the `Preformatted text`

That’s an interesting point of view. You don’t want to try something that works because you think it’s a hack to avoid explaining the problem with something that doesn’t work.

Here’s my point of view: the example I posted meets your stated requirements and is completely independent of whatever other examples posted here. It’s simple, effective, and demonstrates the usefulness and flexibility of a trigger’s id option.

If you prefer to use a longer, more complex (non-working) example, you’re certainly free to do so. Good luck.

2 Likes

lol. your absolutely spot on. i am annoying. i cant disagree with you at all.

even more annoying… i realised I have been calling the wrong device!

i didnt realise DeConz created a group called ‘Outdoor Front’ when I added the light

but the light itself is ‘Front Door Outdoor’: light.front_door_outdoor

so i have changed that in the routine and will see what happens!

so good news. now i am referencing the light directly rather than what i was doing accidentally with the group this is working perfectly.

thanks for everyones help!