Unable to explain this:

I have an automation that stopped working, so I created a new one, guess what, that automation doesn’t work either.

It is a simple turn on light when door opens and the other way around.
I’ve checked the door sensor, works fine.
I’ve checked the lamp, works fine.
I’ve checked the switch, works fine.

But it won’t work:

alias: "Laundry: 🧺 Toggle Light II"
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.sensor_door_laundry_room_contact
    to:
      - "on"
    id: Open Laundry
  - trigger: state
    entity_id:
      - binary_sensor.sensor_door_laundry_room_contact
    to:
      - "off"
    id: Close Laundry
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Open Laundry
        sequence:
          - action: switch.turn_on
            metadata: {}
            target:
              entity_id: switch.laundry_light_power
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Close Laundry
        sequence:
          - action: switch.turn_off
            metadata: {}
            target:
              entity_id: switch.laundry_light_power
            data: {}
mode: single

Let me know if you need more info.

Cheers Starf0x

PS, I’m running the latest version of HA.

What does its trace reveal?


FWIW, here’s a streamlined version.

alias: "Laundry: Toggle Light"
description: ""
triggers:
  - trigger: state
    entity_id: binary_sensor.sensor_door_laundry_room_contact
    to:
conditions:
  - condition: template
    value_template: "{{ has_value(trigger.entity_id) }}"
actions:
  - action: switch.turn_{{ trigger.to_state.state}}
    metadata: {}
    target:
      entity_id: switch.laundry_light_power
    data: {}
mode: single
1 Like

Looks fairly straightforward to me.

What’s it not doing?

Every example of a trigger id uses a slugified id, maybe try open_laundry and close_laundry?

Edit: Nope, that ain’t it.

That said, 123’s streamlined example is your best option.

Edit: Once you’ve identified the problem.

I just finished testing an automation that uses spaces in its Trigger ID and it worked (so it isn’t necessary to slugify it). In fact, the automation’s structure was nearly identical to Starf0x’s example.

Test Automation
alias: Test trigger id
description: ""
triggers:
  - trigger: state
    entity_id:
      - input_boolean.test
    to:
      - "on"
    id: Open It
  - trigger: state
    entity_id:
      - input_boolean.test
    to:
      - "off"
    id: Close It
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Open It
        sequence:
          - action: notify.persistent_notification
            data:
              message: Open It
      - conditions:
          - condition: trigger
            id:
              - Close It
        sequence:
          - action: notify.persistent_notification
            data:
              message: Close It
mode: single

Given that it works, we need to know what Starf0x’s automation trace shows in order to understand why it "won’t work ".

Gotcha. In that case even your streamlined version won’t work until the problem has been identified, and traces are great for that.
wistfully wishes traces were avaiable for trigger based template entities

FrankyB,

What is the switch you are turning on and off?

If a wall switch, I’ve not worked with a smart switch, but I’d imagine you’d need to determine if indeed the switch passes power to the light when toggled by HA.

If the switch is a smart bulb, could it be it switches on but with the bulb at 1% brightness?

Thank you for all the responses.

It is a zigbee wall switch and also a zigbee door sensor. both show a reaction when enforced, so the connectivity is there, the lamp is also working.
But I’m not hearing the familiar click from the switch behind the wallpanel.
But zigbee shows it is alive and kicking.
I have a quite 50+ zigbee environment, so communications errors are not the case.
It worked for years. It happened after the last update of HA.

Thank you.

I like this way of thinking a lot.

Check the Log for any associated errors. However, most importantly, check the automation’s trace.

If the automation has no recent traces, it means the automation has not been triggered recently.