Turn off one outlet when another is turned on

Hi friends. I’m a bit confused and not knowing English complicates me more. I want pump1 to turn on to turn off pump2. What am I doing wrong? Thanks

  - id: '1638316271524'
    alias: Activar Bomba cambio de agua
    description: ''
    trigger:
    - platform: state
      entity_id: switch.pump1
      from: 'off'
      to: 'on'
    condition: []
    action:
    - condition: state
      entity_id: switch.pump2
      attribute: state
      state: 'off'

Your action is wrong:

    action:
    - service: switch.turn_off
      entity_id: switch.pump2

try this for the action:

    action:
    - service: switch.turn_off
      data:
        entity_id: switch.pump2

Don’t cross the streams. :grinning_face_with_smiling_eyes:

Do you always use the data: tag? I find I only need it for some service calls like messages and notifications.

I dunno. I only copied from a working Automation I use but I suspect you’re right and it’s not necessary.

1 Like

Strictly speaking it should be:

    action:
    - service: switch.turn_off
      target:
        entity_id: switch.pump2

But any of the offered solutions would work.

1 Like

Thank you very much to all. It worked