-
Notifications
You must be signed in to change notification settings - Fork 0
/
blind-control.yaml
168 lines (156 loc) · 4.54 KB
/
blind-control.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
substitutions:
device_name: dining-blind #ENSURE THIS MATCHES .YAML FILE NAME IF DEVICE ALREADY CREATED
device_id: dining_blind #CREATE A UNIQUE ID FOR EACH DEVICE
friendly_name: Dining Blind #CREATE A UNIQUE FRIENDLY NAME FOR EACH DEVICE
esphome:
name: ${device_name}
friendly_name: ${friendly_name}_node
platform: ESP8266
board: d1_mini
logger:
ota:
password: !secret ........#YOUR SECRET
wifi:
ssid: !secret ........#YOUR SECRET
password: !secret ........#YOUR SECRET
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_id}_hotspot"
password: !secret ........#YOUR SECRET
captive_portal:
#REMOVE HASHES BELOW TO ENABLE WEB SERVER
#web_server:
# port: 80
api:
encryption:
key: "************************************" #GENERATE AND INSERT ENCRYPTION KEY HERE
services:
- service: control_blind
variables:
target: int
then:
- stepper.set_target:
id: ${device_id}_stepper
target: !lambda 'return target;'
- sensor.template.publish:
id: ${device_id}_position
state: !lambda 'return target;'
cover:
- platform: template
name: "${friendly_name}"
id: ${device_id}_cover_component
device_class: blind
open_action:
- delay: .05s
- stepper.set_target:
id: ${device_id}_stepper
target: 6050
- sensor.template.publish:
id: ${device_id}_position
state: !lambda return id(${device_id}_stepper).target_position;
- delay: 60s
close_action:
- delay: .05s
- stepper.set_target:
id: ${device_id}_stepper
target: 0
- delay: 60s
- sensor.template.publish:
id: ${device_id}_position
state: !lambda return id(${device_id}_stepper).target_position;
stop_action:
- stepper.set_target:
id: ${device_id}_stepper
target: !lambda return id(${device_id}_stepper).current_position;
- sensor.template.publish:
id: ${device_id}_position
state: !lambda return id(${device_id}_stepper).current_position;
optimistic: true
assumed_state: true
sensor:
- platform: template
name: ${friendly_name} Position
id: ${device_id}_position
- platform: wifi_signal
name: ${friendly_name} WiFi Signal
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
- platform: copy
source_id: wifi_signal_db
name: ${friendly_name} WiFi Signal Percent
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "Signal %"
entity_category: "diagnostic"
- platform: uptime
name: ${friendly_name} Uptime
text_sensor:
- platform: wifi_info
ip_address:
name: ${friendly_name} IP Address
ssid:
name: ${friendly_name} SSID
bssid:
name: ${friendly_name} BSSID
mac_address:
name: ${friendly_name} Mac Address
stepper:
- platform: uln2003
id: ${device_id}_stepper
pin_a: D1
pin_b: D2
pin_c: D5
pin_d: D6
max_speed: 250 steps/s
sleep_when_done: true
binary_sensor:
- platform: status
name: ${friendly_name} Status
- platform: gpio
pin:
number: D3
inverted: TRUE
mode:
input: TRUE
pullup: TRUE
name: ${friendly_name} Open Button
filters:
- delayed_on: 10ms
on_multi_click:
#SINGLE CLICK
- timing:
- ON for at most 0.5s
- OFF for at least 0.5s
then:
- delay: .05s
- stepper.set_target:
id: ${device_id}_stepper
target: 0
- delay: 60s
- sensor.template.publish:
id: ${device_id}_position
state: !lambda return id(${device_id}_stepper).target_position;
- platform: gpio
pin:
number: D4
inverted: TRUE
mode:
input: TRUE
pullup: TRUE
name: ${friendly_name} Close Button
filters:
- delayed_on: 10ms
on_multi_click:
#SINGLE CLICK
- timing:
- ON for at most 0.5s
- OFF for at least 0.5s
then:
- delay: .05s
- stepper.set_target:
id: ${device_id}_stepper
target: 6050
- sensor.template.publish:
id: ${device_id}_position
state: !lambda return id(${device_id}_stepper).target_position;