Zigbee switch turns on at Home Assistant startup

I have a zigbee switch that commands two lights.
When Home Assistant starts, the lights turn on by themselves and I don't know why.
The automations that command these lights don't mention any startup behavior, so this shouldn't happen.
In the Z2M "exposes" tab, there's only a settings for "power on behavior" but it is set to OFF.
I really don't understand. Any suggestions?

Post your automation.

This is in effect when the device physically looses power, what it should to when the power comes back on.

It's actually three automations:

alias: Luci Scale & Cantina 1/3
description: I sensori fanno partire il timer
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.movimento_cantina
    to:
      - "on"
  - trigger: state
    entity_id:
      - binary_sensor.porte_downstairs
    enabled: false
    to:
      - "on"
  - trigger: state
    entity_id:
      - binary_sensor.porta_cantina_contact
    to:
      - "on"
  - trigger: state
    entity_id:
      - binary_sensor.porta_scale_contact
    to:
      - "on"
conditions: []
actions:
  - data:
      duration: "00:02:00"
    target:
      entity_id: timer.tempolucescale
    action: timer.start
mode: single
alias: Luci Scale & Cantina 2/3
description: Quando parte il timer, accendi luce
triggers:
  - entity_id:
      - timer.tempolucescale
    from: idle
    to: active
    trigger: state
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    target:
      entity_id: light.luci_scale_cantina
    data: {}
mode: single

alias: Luci Scale & Cantina 3/3
description: Scaduto il timer, spegni la luce se non c'è nessuno presente
triggers:
  - entity_id:
      - timer.tempolucescale
    from: active
    to: idle
    trigger: state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: binary_sensor.presenza_cantina
            state:
              - "on"
        sequence:
          - action: timer.start
            metadata: {}
            target:
              entity_id: timer.tempolucescale
            data: {}
      - conditions:
          - condition: state
            entity_id: binary_sensor.presenza_cantina
            state:
              - "off"
        sequence:
          - action: light.turn_off
            metadata: {}
            target:
              entity_id: light.luci_scale_cantina
            data: {}
    enabled: false
  - if:
      - condition: state
        entity_id: binary_sensor.attivita_cantina
        state:
          - "on"
    then:
      - action: timer.start
        metadata: {}
        target:
          entity_id: timer.tempolucescale
        data: {}
    else:
      - action: light.turn_off
        metadata: {}
        target:
          entity_id:
            - light.luci_scale_cantina
        data: {}
mode: single

I know, I only mentioned it for "completeness" :slight_smile:

add

not_from:
- unavailable

to all your triggers matching the indentation of to:.

e.g.

  - trigger: state
    entity_id:
      - binary_sensor.movimento_cantina
    to:
      - "on"
    not_from:
      - unavailable

EDIT: Actually, you can simplify your automation by combining the triggers.

alias: Luci Scale & Cantina 1/3
description: I sensori fanno partire il timer
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.movimento_cantina
      - binary_sensor.porte_downstairs
      - binary_sensor.porta_cantina_contact
      - binary_sensor.porta_scale_contact
    to:
      - "on"
    not_from:
      - unavailable
conditions: []
actions:
  - data:
      duration: "00:02:00"
    target:
      entity_id: timer.tempolucescale
    action: timer.start
mode: single
1 Like

Thanks a lot, I'm gonna try and see if it solves.

(BTW: I created the automations using the GUI, that's probably why they are not very "refined")

EDIT: it worked!! Thank you so much!!

1 Like