Last active
July 20, 2020 10:01
-
-
Save Gromina/79d362f63937c05b0fd6574bc0ef3448 to your computer and use it in GitHub Desktop.
ESHhome servo conrol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#button controls state of two servo groups. Each one is opposite to other | |
esphome: | |
name: face | |
platform: ESP8266 | |
board: nodemcuv2 | |
wifi: | |
ssid: hackerspace | |
password: xxxxxxx | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Face Hotspot" | |
password: "12345678" | |
logger: | |
level: DEBUG | |
captive_portal: | |
ota: | |
web_server: | |
port: 80 | |
# two servo groups | |
servo: | |
- id: my_servo | |
output: pwm_output | |
- id: my_servo1 | |
output: pwm_output1 | |
# two pins controlling servo groups via PWM | |
output: | |
- platform: esp8266_pwm | |
id: pwm_output | |
pin: D5 | |
frequency: 50 Hz | |
- platform: esp8266_pwm | |
id: pwm_output1 | |
pin: D6 | |
frequency: 50 Hz | |
# logical switch which changes servo positions on state change | |
switch: | |
- platform: template | |
icon: "mdi:lock" | |
name: "Front Door Lock" | |
id: ser | |
turn_on_action: | |
- servo.write: | |
id: my_servo | |
level: 100.0% | |
- servo.write: | |
id: my_servo1 | |
level: -100.0% | |
- logger.log: "Switch Turned On!" | |
- switch.template.publish: | |
id: ser | |
state: ON | |
turn_off_action: | |
- logger.log: "Switch Turned Off!" | |
- switch.template.publish: | |
id: ser | |
state: OFF | |
- servo.write: | |
id: my_servo | |
level: -100.0% | |
- servo.write: | |
id: my_servo1 | |
level: 100.0% | |
# hardware button sensor. Controls logical switch as a result of button state changes | |
binary_sensor: | |
- platform: gpio | |
pin: | |
number: D1 | |
mode: INPUT_PULLUP | |
inverted: True | |
name: "on off" | |
on_press: | |
then: | |
- switch.turn_on: ser | |
on_release: | |
then: | |
- switch.turn_off: ser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment