-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservo_esphome.yaml
80 lines (68 loc) · 2.28 KB
/
servo_esphome.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# ESPHome configuration for use with https://www.thingiverse.com/thing:1156995
---
substitutions:
device: servo_esphome # Set to desired device name in ESPHome
switch_name: "Default Light Switch" # Set to desired name in Home Assistant
up_position: 40% # Change if your servo is not moving far enough or is hitting the end of travel
down_position: -40% # Change if your servo is not moving far enough or is hitting the end of travel
center_position: 0% # Change if your servo is not moving far enough or is hitting the end of travel
esphome:
name: ${device} # Change this in the substitutions section
platform: ESP8266
board: d1_mini # Set This To Match Your Board
wifi:
networks:
- ssid: !secret wifi_ssid # References WiFi SSID in secrets.yaml
password: !secret wifi_pass # References WiFi Password in secrets.yaml
# hidden: true # Uncomment if your WiFi SSID is hidden
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device} # WiFi SSID used when configured connection fails
password: !secret ap_pass # References AP Wifi Password in secrets.yaml
captive_portal:
# Enable logging
logger:
#web_server: # Optional, Uncomment if wanted
# port: 80
# Enable Home Assistant API
api:
ota:
servo:
- id: my_servo
output: pwm_output
output:
- platform: esp8266_pwm
id: pwm_output
pin: D6 # Set this to match the pin you are using
frequency: 50 Hz # Leave this as-is unless your servo needs a different frequency
switch:
- platform: template
name: ${switch_name} # Change the name at the top of the file
optimistic: true # Leave this set unless you add feedback for the switch state
turn_on_action:
- script.execute: move_up
turn_off_action:
- script.execute: move_down
script:
- id: move_up
then:
- servo.write:
id: my_servo
level: ${up_position}
- delay: 1s
- servo.write:
id: my_servo
level: ${center_position}
- delay: 2s
- servo.detach: my_servo
- id: move_down
then:
- servo.write:
id: my_servo
level: ${down_position}
- delay: 1s
- servo.write:
id: my_servo
level: ${center_position}
- delay: 2s
- servo.detach: my_servo