Linking together multiple switches to act as one

Hi, sorry if this is a dumb question, apparently I can’t think of the right search terms.

I have some switches (one for lights one for curtains), the code for which is like 80 lines each… And I would like to have multiple switches that behave exactly the same… ie a curtain and light switch by the door, and a curtain and light switch by the bed… Is there a way of defining multiple switches (binary sensors) to essentially be the same?

In my config I have:

  • alias: CurtainClosedtoOpen
    trigger:
    platform: event
    event_type: click
    event_data:
    entity_id: binary_sensor.switch_158d000155c1ba
    click_type: single

Would there be a way to do something like:
entity_id: binary_sensor.switch_158d000155c1ba && binary_sensor.switch_158d000149b514

Such that both switches would be processed with the same automation code instead of having to duplicate everything out?

Many thanks!

either seperate the with a comma or use a list…

alias: CurtainClosedtoOpen
trigger:
  platform: event
  event_type: click
  event_data:
  entity_id: binary_sensor.switch_158d000155c1ba, binary_sensor.switch_158d000149b514
  click_type: single

alias: CurtainClosedtoOpen
trigger:
  platform: event
  event_type: click
  event_data:
  entity_id: 
    - binary_sensor.switch_158d000155c1ba
    - binary_sensor.switch_158d000149b514
  click_type: single

You may have to make a list of platforms…

alias: CurtainClosedtoOpen
trigger:
  - platform: event
    event_type: click
    event_data:
    entity_id: 
      - binary_sensor.switch_158d000155c1ba
 -  platform: event
    event_type: click
    event_data:
    entity_id: 
      - binary_sensor.switch_158d000149b514

That should work tho’ I’m not sure with events, it works for other types of triggers.

For instance…

 - alias: 'Plant Battery Check' 
   initial_state: off
   trigger:
     - platform: numeric_state
       entity_id: sensor.miflora_bird_of_paradise_battery, sensor.miflora_trailing_plant_bathroom_battery, sensor.miflora_volcano_fern_battery, sensor.miflora_flowering_fern_battery
       below: 5
       above: 1
   action:
      # Actions are scripts so can also be a list of actions
     - condition: sun
       after: sunset
     - condition: time
       after:  '06:00:00'
       before: '06:01:00' 
     - service: notify.mypushbullet
       data_template:
         message: >
           '{{ trigger.from_state.attributes.friendly_name }} NEEDS a new Battery!'

Thanks for taking the time to reply.

So I just tried with a comma, and the result was that the automation stopped working, for the original switch as well.
I also tried adding additional platform: events, which didn’t work until I realised I needed to add -'s in front (which you did mention). So got there in the end! Though it still seems pretty bloated to add 5 lines per switch instead of just listing the entity_id’s but whatever!

Thanks again.