ESPhome doesn't like this

What am I doing wrong? This is the idea for speed1, speed2, speed3. I want the water pump to turn on first then one of the fans. It works ok without the “- platform: template” and below delay:
"
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
in “/config/esphome/Air Cool1.yaml”, line 33, column 5:
- platform: gpio
^
expected , but found ‘-’
in “/config/esphome/Air Cool1.yaml”, line 42, column 5:
- platform: template
^
"

switch:
  - platform: gpio
    pin: D0
    inverted: True
    icon: "mdi:fan-speed-1"
    name: "cool-fan-speed-1"
    id: speed1
    interlock: &interlock_group [speed1, speed2, speed3, HVAC_heat]
    interlock_wait_time: 5s
    restore_mode: ALWAYS_OFF
  - platform: template
    turn_on_action:
    - delay: 30s
    - switch.turn_on: speed1

I know less about ESPHome and YAML than most others here, but I run my YAML code through a YAML Lint.

switch: 
  - 
    icon: "mdi:fan-speed-1"
    id: speed1
    interlock: 
      - speed1
      - speed2
      - speed3
      - HVAC_heat
    interlock_wait_time: 5s
    inverted: true
    name: cool-fan-speed-1
    pin: D0
    platform: gpio
    restore_mode: ALWAYS_OFF
  - 
    platform: template
    turn_on_action: 
      - 
        delay: 30s
      - 
        switch.turn_on: speed1

Try that. In my own code I always put a blank line before each new -platform.

For starter your indentation is wrong, under “turn on action” - lines below that (delay and turn.on…) should be two spaces to the right. Yaml is VERY picky for indentation.

I got an error not having a name for the interlock, so I added “&interlock_group” after "interlock: "

Then I get the following error:

  • INFO Reading configuration /config/esphome/xxxx.yaml…

  • Failed config

  • switch.template: [source /config/esphome/xxxx.yaml:48]

  • At least one of ‘id:’ or ‘name:’ is required!.

  • platform: template

  • turn_on_action:

  • - delay: 30s
    
  • - switch.turn_on: speed1
    

I will continue to try different things

Here is what finally validated, plus the next switch displayed here. Had to change some logic here as well. I will wait for comments before changing my other three switches.

switch: 
  - platform: gpio
    icon: "mdi:fan-speed-1"
    id: speed1
    interlock: &interlock_group
      - speed1
      - speed2
      - speed3
      - HVAC_heat
    interlock_wait_time: 5s
    inverted: true
    pin: D0
    restore_mode: ALWAYS_OFF
  - platform: template
    name: "cool-fan-speed-1"
    turn_on_action:
      - delay: 30s
      - switch.turn_on: speed1
  
  - platform: gpio
    pin: D1
    inverted: True
    icon: "mdi:fan-speed-2"
    name: "cool-fan-speed-2"
    id: speed2
    interlock: *interlock_group
    interlock_wait_time: 5s
    restore_mode: ALWAYS_OFF

After much testing I have concluded the delay is not provided as the docs say. I am using a D1-mini, so now I am thinking the hardware probably does not support it in the template. I was able to get a delay in one test by changing names and ID to the same name, but this would not allow me to have interlock and I didn’t have an action to turn the switch off or publish the template state.
I am just going to leave the switches in interlock configuration and do the delay with automation.

Delay is not depending on special hardware. So either what you want to do is gernal not supported or you have configured it wrong. For me it is not clear which delay is not working.

is not working. I tried different methods, but unsuccessful. To reiterate, I would like each motor speed to delay 30-40 seconds 40 secs now, then when I use the programmable thermostat it will turn on the water pump first, delay 40 seconds to turn the motor speed on. The programmer for Programmable Thermostat has not worked on the project for over a year. I am thinking of learning python to add this feature. But if it would be easier to do it here then fine. Now yaml accepts all the tried syntax’s, but the mini-d1 doesn’t respond to the delay commands. or when validating with ESPhome the code errors.

You mean the interlock_wait_time? Ah OK.

But still that is just a software thing. It has nothing to do with your esp8266.

If that really is not working you should consider to open an issue.

Maybe a or more scripts are an option to do what you want.