Trying to use wait_until in a template switch, but it won't compile

I want to make a template switch for the motor tilt on my boat that checks if the jackplate (for lifting the motor) is at the top (with a coil spring limit switch) and executes if it is. If the jackplate isn’t at the top, it should wait for up to 30 seconds for the jackplate to reach the top and then execute for 25 seconds. If it starts to tilt before the jackplate is in the top position, the steering cylinder will hit the transom, which can damage it.

But I’m starting to wonder if maybe the wait_until action doesn’t work as I thought? Here’s the template switch:

  - platform: template
    name: "Tilt up-switch"
    id: tiltupswitch
    turn_on_action:
      wait_until:
        condition:
          binary_sensor.is_on: jackplatetop #binary sensor with a coil spring limit switch
        timeout: 30s
      - switch.turn_on: tiltup #Relay for tilt up
      - delay: 25s
      - switch.turn_off: tiltup #Relay for tilt up

Can somebody help me out a bit here? I get:

ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
  in "hekk.yaml", line 356, column 7:
          wait_until:
          ^
expected <block end>, but found '-'
  in "hekk.yaml", line 360, column 7:
          - switch.turn_on: tiltup
          ^

The syntax error here is that you have one action AND also a list of other actions as the value of the turn_on_action key. You can fix the syntax by error by making the wait_until Action to be the first item in the list, like this:

  - platform: template
    name: "Tilt up-switch"
    id: tiltupswitch
    turn_on_action:
      - wait_until:
          condition:
            binary_sensor.is_on: jackplatetop #binary sensor with a coil spring limit switch
          timeout: 30s
      - switch.turn_on: tiltup #Relay for tilt up
      - delay: 25s
      - switch.turn_off: tiltup #Relay for tilt up

I don’t happen to know if fixing the syntax in this way will get the result you want though…

2 Likes

Thank you very much! I had to change the indentation a bit too, but now it’s working as intended!