Disabling ESPHome device based on HA Input Boolean

I’m trying to prevent an ESPHome device, from taking actions, based on the state of an input boolean within home assistant.

So if the input boolean is off then stop the cover on a esphome device from opening/closing. If the boolean is on then allow the cover to operate normally.

I keep rolling my face on the keyboard and it’s not working. Any help would appreciated.

Whether or not the pool is open for the summer
input_boolean.pool_open

esphome device for controlling the pool cover:

switch:
  - platform: gpio
    pin: GPIO16
    id: relay_1
    name: Relay 1
    internal: true
    interlock: [relay_2]

  - platform: gpio
    pin: GPIO17
    id: relay_2
    name: Relay 2
    internal: true
    interlock: [relay_1]

cover:
  - platform: template
    name: "Pool Cover"
    id: pool_cover
    open_action:
      - switch.turn_on: relay_1
      - delay: 1000ms
      - switch.turn_off: relay_1
      - delay: 1000ms
      - switch.turn_on: relay_1
      - delay: 24000ms
      - switch.turn_off: relay_1
      - cover.template.publish:
          id: pool_cover
          state: OPEN
    close_action:
      - switch.turn_on: relay_2
      - delay: 1000ms
      - switch.turn_off: relay_2
      - delay: 1000ms
      - switch.turn_on: relay_2
      - delay: 33000ms
      - switch.turn_off: relay_2
      - cover.template.publish:
          id: pool_cover
          state: CLOSED

Right, but how do I disable the cover entity in esphome - not take actions based on the sensor.

You add an if to your cover’s action sequences, so it doesn’t do anything unless the desired conditions are met.

And I would not make it based on a HA sensor but add a switch for it in the ESP. Something like:

switch:
  - platform: gpio
    pin: GPIO16
    id: relay_1
    name: Relay 1
    internal: true
    interlock: [relay_2]

  - platform: gpio
    pin: GPIO17
    id: relay_2
    name: Relay 2
    internal: true
    interlock: [relay_1]
  
  - platform: template
    name: "Lock"
    id: cover_lock
    optimistic: true
    restore_mode: RESTORE_DEFAULT_OFF

cover:
  - platform: template
    name: "Pool Cover"
    id: pool_cover
    open_action:
      - if:
          condition:
             - switch.is_off: cover_lock
          then:
            - switch.turn_on: relay_1
            - delay: 1000ms
            - switch.turn_off: relay_1
            - delay: 1000ms
            - switch.turn_on: relay_1
            - delay: 24000ms
            - switch.turn_off: relay_1
            - cover.template.publish:
                id: pool_cover
                state: OPEN
    close_action:
      - if:
          condition:
             - switch.is_off: cover_lock
          then:
            - switch.turn_on: relay_2
            - delay: 1000ms
            - switch.turn_off: relay_2
            - delay: 1000ms
            - switch.turn_on: relay_2
            - delay: 33000ms
            - switch.turn_off: relay_2
            - cover.template.publish:
                id: pool_cover
                state: CLOSED
2 Likes

Ahhh, I was misunderstanding the docs, didn’t grok that the if could be on any component. Thank you

Thanks septillion <3