forked from 14yannick/esphome-hcpbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_hcpbridge.yaml
200 lines (183 loc) · 4.73 KB
/
example_hcpbridge.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
esphome:
name: hcpbridge
libraries:
- emelianov/modbus-esp8266
platformio_options:
board_build.f_cpu: 240000000L
board_build.flash_mode: qio
monitor_speed: 9600
monitor_filters: esp32_exception_decoder
lib_ldf_mode: deep+
# board_build.f_flash: 40000000L
external_components:
source: github://14yannick/esphome-hcpbridge
refresh: 0s
esp32:
board: adafruit_feather_esp32s3
framework:
type: arduino
hcpbridge:
is_connected:
name: "HCPBridge Connected"
id: hcpbridge_id
rx_pin: 18 # optional, default=18
tx_pin: 17 # optional, default=17
#rts_pin : 1 # optional RTS pin to use if hardware automatic control flow is not available.
cover:
- platform: hcpbridge
name: Garage Door
device_class: garage
id: garagedoor_cover
binary_sensor:
- platform: template
name: "Garage Door Light sensor"
internal: true
device_class: light
id: sensor_light
lambda: !lambda |-
return (id(garagedoor_cover).get_light_state());
on_state:
#needed to correct the state fo the light
if:
condition:
or:
- and:
- binary_sensor.is_on: sensor_light
- light.is_off: light_1
- and:
- binary_sensor.is_off: sensor_light
- light.is_on: light_1
then:
- light.toggle: light_1
- platform: template
name: "relay state"
id: sensor_relay
lambda: !lambda |-
return (id(garagedoor_cover).get_relay_state());
#on_state:
#create your automation based on relay state
output:
- platform: template
type: binary
id: output_light
write_action:
lambda: !lambda |-
id(garagedoor_cover).set_light_state(state);
light:
- platform: binary
output: output_light
id: light_1
name: Garage Door Light
button:
platform: template
id: button_vent
name: "Garage Door Vent"
on_press:
- lambda: |-
id(garagedoor_cover).on_go_to_vent();
text_sensor:
- platform: template
id: sensor_templ_state
name: "Garage Door State"
update_interval: 5s
filters:
- lambda: |-
static std::string last;
if (x == last)
return {};
last = x;
return x;
lambda: |-
std::string stateText;
switch (id(garagedoor_cover).get_cover_state()) {
case HoermannState::OPENING:
stateText = "opening";
break;
case HoermannState::MOVE_VENTING:
stateText = "move venting";
break;
case HoermannState::MOVE_HALF:
stateText = "move half";
break;
case HoermannState::CLOSING:
stateText = "closing";
break;
case HoermannState::OPEN:
stateText = "open";
break;
case HoermannState::CLOSED:
stateText = "closed";
break;
case HoermannState::STOPPED:
stateText = "stopped";
break;
case HoermannState::HALFOPEN:
stateText = "half open";
break;
case HoermannState::VENT:
stateText = "venting";
break;
default:
stateText = "unknown";
break;
}
return {stateText};
switch:
- platform: template
id: switch_vent
name: "Venting"
lambda: |-
return (id(garagedoor_cover).get_cover_state() == HoermannState::VENT);
optimistic: True
turn_on_action:
- lambda: |-
if (id(garagedoor_cover).get_cover_state() != HoermannState::VENT) {
id(garagedoor_cover).on_go_to_vent();
}
turn_off_action:
#without wait device not booting
- wait_until:
condition:
binary_sensor.is_on: hcpbridge_id
- if:
condition:
lambda : |-
return (id(garagedoor_cover).position != COVER_CLOSED);
then:
- cover.close: garagedoor_cover
api:
encryption:
key: !secret api_key
services:
- service: go_to_open
then:
- lambda: |-
id(garagedoor_cover).on_go_to_open();
- service: go_to_close
then:
- lambda: |-
id(garagedoor_cover).on_go_to_close();
- service: go_to_half
then:
- lambda: |-
id(garagedoor_cover).on_go_to_half();
- service: go_to_vent
then:
- lambda: |-
id(garagedoor_cover).on_go_to_vent();
web_server:
port: 80
auth:
username: !secret web_username
password: !secret web_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable logging
logger:
level: DEBUG
baud_rate: 9600
# Example configuration entry
ota:
- platform: esphome
safe_mode: true