Trying to make a simple servo lock with a trigger button using esphome.
Using the code below I can turn on and off the lock from HA but the button on esphome only turns the lock on. Its not acting like a push button switch???
Im still a beginner with yaml code but I tried copying from others and docs and this is what I came up with. I was actually surprised nobody tried doing this already.
esphome:
name: front_door_lock_servo
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "*"
password: ""
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
# Example configuration entry
servo:
- id: my_servo
output: pwm_output
output:
- platform: esp8266_pwm
id: pwm_output
pin: D4
frequency: 50 Hz
switch:
- platform: template
icon: "mdi:lock"
name: "Front Door Lock"
id: ser
turn_on_action:
- servo.write:
id: my_servo
level: 100.0%
turn_off_action:
- servo.write:
id: my_servo
level: -0.0%
binary_sensor:
- platform: gpio
pin:
number: D0
mode: INPUT_PULLUP
inverted: True
name: "on off"
on_press:
then:
- switch.toggle: ser