ESPHome: Cannot have two actions in one item. Key 'servo.write' overrides 'id'!

Hello, I’m very new to ESPHome but liking it so far. I’m working to make a Time Based Cover with a continuous rotation servo. I think I’m having a bit of trouble either with my YAML formatting or with understanding how Actions are supposed to work in the first place with ESPHome.

The error I’m recieving is:

INFO Reading configuration...
Failed config

cover.time_based: [source /config/esphome/test111.yaml:39]
  platform: time_based
  name: Time-Based Cover
  open_action: 
    
    Cannot have two actions in one item. Key 'servo.write' overrides 'id'! Did you forget to indent the block inside the action?.
    - [source /config/esphome/test111.yaml:43]
      servo.write: 
      id: my_servo
      level: 100.0%
  open_duration: 30sec
  close_action: 
    
    Cannot have two actions in one item. Key 'servo.write' overrides 'id'! Did you forget to indent the block inside the action?.
    - [source /config/esphome/test111.yaml:49]
      servo.write: 
      id: my_servo
      level: -100.0%
  close_duration: 30sec
  stop_action: 
    
    Cannot have two actions in one item. Key 'servo.write' overrides 'id'! Did you forget to indent the block inside the action?.
    - [source /config/esphome/test111.yaml:55]
      servo.write: 
      id: my_servo
      level: 0.0%

My code is as follows:

esphome:
  name: test111
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "XXXXXXXX"
  password: "XXXXXXXX"

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "XXXXXXXX"

ota:
  password: "XXXXXXXX"
  
switch:
  - platform: gpio
    name: "Test Status Light"
    pin: 2
    inverted: True
    
servo:
  - id: my_servo
    output: pwm_output

# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D1
    frequency: 50 Hz

cover:
  - platform: time_based
    name: "Time-Based Cover"

    open_action:
      - servo.write:
        id: my_servo
        level: 100.0%
    open_duration: 30sec

    close_action:
      - servo.write:
        id: my_servo
        level: -100.0%
    close_duration: 30sec

    stop_action:
      - servo.detach: my_servo

Thanks for any input on formatting or my lack of understanding.

Ok so I’ve gotten a bit further. Now I can compile.
I’ve got no sign of life on the servo though. Strange.

servo:
  - id: my_servo
    output: pwm_output

# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D5
    frequency: 50 Hz

cover:
  - platform: time_based
    name: "Time-Based Cover"
    open_action:
#      then:
      - servo.write:
          id: my_servo
          level: 30.0%
    open_duration: 5sec

    close_action:
#      then:
      - servo.write:
          id: my_servo
          level: -30.0%
    close_duration: 5sec

    stop_action:
#      then:
      - servo.detach: my_servo

I’ll keep playing around with it.

Are you sure 30% works for your servo? Try other values: 2 5 10 80

1 Like

Thanks I’ll try that tonight.
It’s a continuous rotation servo.
I thought all that affected was speed.
In fairness I don’t think I said it was.

Ok so I think this is pretty much fixed now.
I put in some code to close the cover on boot. I would prefer to “stop” it but it doesn’t seem to be working… I’ll update again if I get that fixed…

Faux Wood Blind devices incoming…
Here’s the code:

esphome:
  name: test111
  platform: ESP8266
  board: d1_mini
  on_boot:
    priority: 800.0
    then:
      - cover.close: cover1

wifi:
  ssid: "APSSID"
  password: "APPASS"

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "APIPASS"

ota:
  password: "OTAPASS"
  
switch:
  - platform: gpio
    name: "Test Status Light"
    pin: 2
    inverted: True

servo:
  - id: my_servo
    output: pwm_output

# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D5
    frequency: 50 Hz

cover:
  - platform: time_based
    name: "Time-Based Cover"
    id: cover1
    open_action:
#      then:
      - servo.write:
          id: my_servo
          level: 20.0%
    open_duration: 2sec

    close_action:
#      then:
      - servo.write:
          id: my_servo
          level: -20.0%
    close_duration: 2sec

    stop_action:
#      then:
      - servo.write:
          id: my_servo
          level: 0%
      - servo.detach: my_servo

Stop does not work because esphome doesn’t execute the stop action if the cover is already in stop position

However this will be changed for the next version and stop action will be executed every time.

Awesome!
I look forward to implementing it!

@keithcroshaw Would you mind sharing your home assistant configuration? I’ve been trying to control a servo but haven’t had any luck

What specifically?
My config isn’t as !Secret’d up as I’d like.
If you set up the ESPHome code as Covers properly there’s no code to be shared. They just appear as devices in Home Assistant after adding them with the API Password.

I used the code you posted for the esphome part now I’m not sure how the setup the rest in home assistant. What else did you have setup and can you post that part? input_number? automation? cover? I appreciate your help

Not sure what the part is. They’re HiTec Continuous Rotation Servos.

One on Pin 5 and one on Pin 6.

Here’s the code:

esphome:
  name: lrf_blinds
  platform: ESP8266
  board: d1_mini
  on_boot:
    priority: 800.0
    then:
      - cover.close: cover1
      - delay: 2s
      - servo.detach: my_servo
      - delay: 3s
      - cover.close: cover2
      - delay: 2s
      - servo.detach: my_servo2

wifi:
  ssid: "REDACTED"
  password: "REDACTED"
  manual_ip:
    static_ip: 192.168.1.230
    gateway: 192.168.1.1
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "REDACTED"

ota:
  password: "REDACTED"
  
switch:
  - platform: gpio
    name: "Living Room Front Blinds Status Light"
    pin: 2
    inverted: True

servo:
  - id: my_servo
    output: pwm_output
    
  - id: my_servo2
    output: pwm_output2

# Example output platform
# On ESP32, use ledc output
output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D5
    frequency: 50 Hz

  - platform: esp8266_pwm
    id: pwm_output2
    pin: D6
    frequency: 50 Hz

cover:
  - platform: time_based
    name: "Living Room Front Blinds Left"
    id: cover1
    open_action:
#      then:
      - servo.write:
          id: my_servo
          level: -2.0%
    open_duration: 1.2sec

    close_action:
#      then:
      - servo.write:
          id: my_servo
          level: 20.0%
    close_duration: 2.3sec

    stop_action:
#      then:
      - servo.write:
          id: my_servo
          level: 0%
      - servo.detach: my_servo
###############################
  - platform: time_based
    name: "Living Room Front Blinds Right"
    id: cover2
    open_action:
#      then:
      - servo.write:
          id: my_servo2
          level: -2.0%
    open_duration: 3.5sec

    close_action:
#      then:
      - servo.write:
          id: my_servo2
          level: 20.0%
    close_duration: 1sec

    stop_action:
#      then:
      - servo.write:
          id: my_servo2
          level: 0%
      - servo.detach: my_servo2


The automation is in Node-Red

I don’t know what this question means. If you create the cover device in the ESPHome software, when you add the ESPHome device into Home Assistant it should come in as a cover automatically.