Problem with automation (Does it activate itself?)

Hello everyone. I am having problems with this automation and it is not possible to verify what the problem is.
Wake automation is a light when others turn off
The problem is that at night it activates itself randomly
It occurs to me to ask if the light that goes off was on for a few seconds, but I don’t know how.
I hope the translation is understood.
Thank you very much.

  - alias: "Enciende pasillo a media luz cuando apague alguna luz a la noche"
    mode: parallel
    trigger:
      - platform: state
        entity_id: switch.cocina 
        to: "off"
      - platform: state
        entity_id: switch.banio 
        to: "off"
      - platform: state
        entity_id: switch.cuarto_florencia
        to: "off"
      - platform: state
        entity_id: switch.cuarto_principal
        to: "off"
      - platform: state
        entity_id: switch.cuarto_milena
        to: "off"
    condition:
      - condition: and
        conditions:
          - condition: state
            entity_id: switch.comedor_1
            state: "off"
          - condition: state
            entity_id: switch.comedor_2
            state: "off"
          - condition: state
            entity_id: switch.10010f3073
            state: "off"
          - condition: state
            entity_id: sun.sun
            state: "below_horizon"
    action:
      - service: light.turn_on
        target:
          entity_id: light.luz_pasillo # deberia haber un grupo para que se enciendan todas
        data:
          brightness: 3
          kelvin: 2700
      - delay:
          seconds: 10  
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_1
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_2
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_3
      - service: switch.turn_off
        target:
          entity_id: switch.10010f3073

The problem is likely that one or more switch is momentarily ‘unavailable’ or ‘unknown’ then returns to ‘off’, triggering the automation. To fix it, set a “from: on” for each trigger.

En Español

Es probable que el origen del problema es que uno de los interruptores estén momentáneamente “no disponibles” o “desconocidos” y luego regresen a “off”, lo cual iniciará la automatización. Para solucionarlo, establezca un “from: on” para cada gatillo.

Ademas, el condición “And” no es necessario en este caso porque los condiciones son “And” de moda predeterminada.

  - alias: "Enciende pasillo a media luz cuando apague alguna luz a la noche"
    mode: parallel
    trigger:
      - platform: state
        entity_id: switch.cocina 
        to: "off"
        from: "on"
      - platform: state
        entity_id: switch.banio 
        from: "on"
        to: "off"
      - platform: state
        entity_id: switch.cuarto_florencia
        from: "on"
        to: "off"
      - platform: state
        entity_id: switch.cuarto_principal
        from: "on"
        to: "off"
      - platform: state
        entity_id: switch.cuarto_milena
        from: "on"
        to: "off"
    condition:
        - condition: state
          entity_id: switch.comedor_1
          state: "off"
        - condition: state
          entity_id: switch.comedor_2
          state: "off"
        - condition: state
          entity_id: switch.10010f3073
          state: "off"
        - condition: state
          entity_id: sun.sun
          state: "below_horizon"
    action:
      - service: light.turn_on
        target:
          entity_id: light.luz_pasillo # deberia haber un grupo para que se enciendan todas
        data:
          brightness: 3
          kelvin: 2700
      - delay:
          seconds: 10  
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_1
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_2
      - service: light.turn_off
        target:
          entity_id: light.luz_pasillo_3
      - service: switch.turn_off
        target:
          entity_id: switch.10010f3073

Very likely that will happen. I’ll change it and then I’ll tell you. Thank you very much for the reply

For future reference, it isn’t necessary to define five State Triggers, one for each switch entity. You can consolidate them into a single State Trigger.

    trigger:
      - platform: state
        entity_id:
          - switch.cocina
          - switch.banio
          - switch.cuarto_florencia
          - switch.cuarto_principal
          - switch.cuarto_milena
        from: 'on'
        to: 'off'

Better. Thanks

Can the same be applied to conditions?

Yes, and you can combine your turn_off actions as well… you can use the generic homeassistant.turn_off on both lights and switches.


alias: "Enciende pasillo a media luz cuando apague alguna luz a la noche"
mode: parallel
trigger:
  - platform: state
    entity_id:
      - switch.cocina
      - switch.banio
      - switch.cuarto_florencia
      - switch.cuarto_principal
      - switch.cuarto_milena
    from: 'on'
    to: 'off'
condition:
  - condition: state
    entity_id:
       - switch.cocina
       - switch.banio
       - switch.cuarto_florencia
       - switch.cuarto_principal
       - switch.cuarto_milena
     state: 'off'
action:
  - service: light.turn_on
    target:
      entity_id: light.luz_pasillo # deberia haber un grupo para que se enciendan todas
    data:
      brightness: 3
      kelvin: 2700
  - delay:
      seconds: 10  
  - service: homeassistant.turn_off
    target:
      entity_id:
        - light.luz_pasillo_1
        - light.luz_pasillo_2
        - light.luz_pasillo_3
        - switch.10010f3073

Perfect. Thanks
Unfortunately I keep getting false positives and it turns on by itself. What can I do to check which device is turning on?