-
Notifications
You must be signed in to change notification settings - Fork 23
/
sonoff_rf_bridge_and_many_time_based_covers.yaml
186 lines (154 loc) · 5.13 KB
/
sonoff_rf_bridge_and_many_time_based_covers.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
# Sonoff RF Bridge with many configured Time Based RF covers.
#
# The covers can be controlled with RF codes decoded with 'portisch bit bucket converter'. Up/Down/Stop each have a different code.
# ESPHome cand send these codes out as raw with rf_bridge component, and time based covers can be set up with actions to send the
# codes out for each command.
# Operating the covers one by one, by hand, from the UI - everything is fine. Each cover opens or closes as it should.
# The problem occurs when using service calls in HA to operate multiple covers at once: only the first one in the list reacts,
# the others don't move.
# I found by trial and error is that the cover motors simply don't accept the RF codes transmitted by the RF Bridge if they are sent
# too fast after each other. I found the same using Tasmota too. Looks loke the cover motors need at least 600-700ms of silence between
# code transmissions to be able to recognize them.
# The solution below handles this, by building up a queue of raw RF codes and sending them out one after the other with a configurable
# delay between them. If only one cover is operated, no delay occurs. Delay is only added to the next commands coming from a list of
# covers which have to be operated at once from Home Assistant. This is transparent to the system, which will still look like they
# operate simultaneously. Thanks to @ssieb for the vector queue solution.
substitutions:
device_name: sonoff-rf-bridge
friendly_name: "RF Bridge"
device_ip: 192.168.81.22
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
esp8266_restore_from_flash: true
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: ${device_ip}
gateway: 192.168.81.254
subnet: 255.255.255.0
use_address: ${device_ip}
logger:
baud_rate: 0
level: INFO
uart:
tx_pin: GPIO01
rx_pin: GPIO03
baud_rate: 19200
rf_bridge:
api:
reboot_timeout: 15min
password: !secret api_password
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
sensor:
- platform: wifi_signal
name: ${friendly_name} WiFi signal
update_interval: 120s
- platform: uptime
name: ${friendly_name} uptime
- platform: template
name: ${friendly_name} free memory
lambda: return ESP.getFreeHeap();
icon: "mdi:memory"
entity_category: diagnostic
state_class: measurement
unit_of_measurement: "b"
update_interval: 60s
status_led:
pin:
number: GPIO13
inverted: true
binary_sensor:
- platform: status
name: ${friendly_name} network
button:
- platform: restart
name: ${friendly_name} restart
number:
- platform: template
name: Delay commands
icon: mdi:clock-fast
entity_category: config
optimistic: true
restore_value: true
initial_value: 750
unit_of_measurement: "ms"
id: queue_delay
min_value: 10
max_value: 1000
step: 50
mode: box
globals:
- id: rf_code_queue
type: 'std::vector<std::string>'
script:
- id: rf_transmitter_queue
mode: single
then:
while:
condition:
lambda: 'return !id(rf_code_queue).empty();'
then:
- rf_bridge.send_raw:
raw: !lambda |-
std::string rf_code = id(rf_code_queue).front();
id(rf_code_queue).erase(id(rf_code_queue).begin());
return rf_code;
- delay: !lambda 'return id(queue_delay).state;'
cover:
- platform: time_based
name: 'My Room 1'
disabled_by_default: false
device_class: shutter
assumed_state: true
has_built_in_endstop: true
close_action:
- lambda: id(rf_code_queue).push_back("AAB0XXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
close_duration: 26s
stop_action:
- lambda: id(rf_code_queue).push_back("AAB0YXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_action:
- lambda: id(rf_code_queue).push_back("AAB0ZXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_duration: 27s
- platform: time_based
name: 'My Room 2'
disabled_by_default: false
device_class: shutter
assumed_state: true
has_built_in_endstop: true
close_action:
- lambda: id(rf_code_queue).push_back("AAB0XXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
close_duration: 26s
stop_action:
- lambda: id(rf_code_queue).push_back("AAB0YXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_action:
- lambda: id(rf_code_queue).push_back("AAB0ZXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_duration: 27s
- platform: time_based
name: 'My Room 3'
disabled_by_default: false
device_class: shutter
assumed_state: true
has_built_in_endstop: true
close_action:
- lambda: id(rf_code_queue).push_back("AAB0XXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
close_duration: 26s
stop_action:
- lambda: id(rf_code_queue).push_back("AAB0YXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_action:
- lambda: id(rf_code_queue).push_back("AAB0ZXXXX....XXXXXXXXXX");
- script.execute: rf_transmitter_queue
open_duration: 27s