Hi all,
I am attempting to update my ESP, used for opening/closing my garage door, but am receiving the following error:
INFO Reading configuration /config/esphome/garage-door.yaml…
ERROR Error while reading config: Invalid YAML syntax:
Duplicate key “name”
in “/config/esphome/garage-door.yaml”, line 86, column 5:
name: “Garage door closed”
^
NOTE: Previous declaration here:
in “/config/esphome/garage-door.yaml”, line 82, column 5:
name: “Garage door open”
^
I am assuming it is a formatting error but this code worked without problem previously:
binary_sensor:
- platform: status
name: "Garage Door ESP Status"
- platform: template
name: "Garage door open"
value_template: >-
{{ is_state('switch.garage_door_open', 'on') }}
name: "Garage door closed"
value_template: >-
{{ is_state('switch.garage_door_close', 'on') }}
Could anyone point me to what’s going wrong (I have attempted reformatting without success)
INFO Reading configuration /config/esphome/garage-door.yaml…
INFO Detected timezone ‘Europe/London’
Failed config
binary_sensor.template: [source /config/esphome/garage-door.yaml:81]
platform: template
name: Garage door open
[value_template] is an invalid option for [binary_sensor.template]. Please check the indentation.
value_template: {{ is_state(‘switch.garage_door_open’, ‘on’) }}
binary_sensor.template: [source /config/esphome/garage-door.yaml:86]
platform: template
name: Garage door closed
[value_template] is an invalid option for [binary_sensor.template]. Please check the indentation.
value_template: {{ is_state(‘switch.garage_door_close’, ‘on’) }}
Sorry, I wasn’t paying attention to the actual sensor configuration, but only the syntax.
Looking back at your original configuration: You appear to have 2 switches defined - are these switches defined on the ESP device? If so, the proper way would be to give each switch an ID, and then use those IDs in the template sensors’ lambdas.
So, for example, if you give one switch the ID garage_door_open, then the lambda would look something like:
- platform: template
name: "Garage door open"
lambda: 'return id(garage_door_open).state;'
Hi,
Yes the switches are defined within the ESP config, I am attempting to update within ESP home but my config is now showing the errors above (although it did previously work).
Well, those lambda statements underneath binary_sensor won’t work. But you should now be able to insert my previously suggested template binary sensor and that should work just fine.
And because the switches are actually template switches you could also toggle the template binary sensor from within the switches with the binary_sensor.template.publish action.