Automation Help - Automating LED lights on door actions

Hi,

I have a cupboard with a LED strip in it, i have an esp setup with two magnetic sensors on the doors, left and right door.

I want the light on when either of the doors are open and the light off when either are shut

I have this automation, which works well for doors open, but does not for doors closed, so i need to split this out into its own automation or can it all be done in one?

alias: Office Cupboard LED Strip
description: Turns on LED strip if cupboard doors are opened.
trigger:
  - platform: state
    entity_id:
      - binary_sensor.left_door_status
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - binary_sensor.right_door_status
    from: "off"
    to: "on"
condition:
  - condition: state
    entity_id: switch.powerboard_pb89ha_socket_1
    state: "off"
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.powerboard_pb89ha_socket_1
  - if:
      - condition: state
        entity_id: binary_sensor.left_door_status
        state: "off"
      - condition: state
        entity_id: binary_sensor.right_door_status
        state: "off"
    then:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.powerboard_pb89ha_socket_1
mode: single

You’re automation isn’t triggered if a door closes, only when it opens. So you should add a trigger for that as well. You could also trigger it on state change instead of using from “off” to “on”.

After that I would remove the condition (not sure what you wanted with that?).

And then in the actions make the split. If both are off, then turn_off. ELSE turn_on.
Would probably be a lot simpeler and more understandable.

alias: Office Cupboard LED Strip
trigger:
  - platform: state
    entity_id:
      - binary_sensor.left_door_status
      - binary_sensor.right_door_status
    from: 
      - "off"
      - "on"
    to:
      - "on"
      - "off"
condition: []
action:
  - service: 'switch.turn_{{ trigger.to_state.state }}'
    target:
      entity_id: switch.powerboard_pb89ha_socket_1
mode: single