@@ -3,11 +3,16 @@ packages:
33
44esphome :
55 on_boot :
6+ priority : 300
67 then :
8+ # Signal to the template switches that their initial values have been loaded
79 - lambda : |
810 if (id(voltage_multiply) <= 0) id(voltage_multiply) = 0.3;
911 if (id(power_multiply) <= 0) id(power_multiply) = 0.133;
1012 if (id(current_multiply) <= 0) id(current_multiply) = 0.85;
13+ - globals.set :
14+ id : setupComplete
15+ value : " true"
1116
1217wifi :
1318 power_save_mode : high
@@ -64,6 +69,11 @@ globals:
6469 restore_value : true
6570 initial_value : " 0.805"
6671
72+ - id : setupComplete
73+ type : bool
74+ restore_value : no
75+ initial_value : " false"
76+
6777binary_sensor :
6878 # Push Button (Toggles Relay When Pressed)
6979 - platform : gpio
@@ -107,40 +117,46 @@ switch:
107117 condition :
108118 switch.is_off : disable_led
109119 then :
110- light.turn_on :
111- id : led
120+ light.turn_on : led
112121 on_turn_off :
113- - light.turn_off :
114- id : led
115-
122+ - light.turn_off : led
123+
116124 - platform : template
117125 name : " Disable LED"
118126 id : disable_led
119127 icon : " mdi:led-variant-off"
120- restore_mode : " ${default_state }"
128+ restore_mode : " ${disable_led_default_state }"
121129 optimistic : true
122130 on_turn_on :
123- # Flash twice
124- - light.turn_off : led
125- - delay : 0.1s
126- - light.turn_on : led
127- - delay : 0.1s
128- - light.turn_off : led
129- - delay : 0.1s
130- - light.turn_on : led
131- - delay : 0.1s
131+ - if :
132+ condition :
133+ lambda : ' return id(setupComplete) == true;'
134+ then :
135+ # Flash twice
136+ - light.turn_off : led
137+ - delay : 0.15s
138+ - light.turn_on : led
139+ - delay : 0.15s
140+ - light.turn_off : led
141+ - delay : 0.15s
142+ - light.turn_on : led
143+ - delay : 0.15s
132144 # Final state
133145 - light.turn_off : led
134146 on_turn_off :
135- # Flash twice
136- - light.turn_on : led
137- - delay : 0.1s
138- - light.turn_off : led
139- - delay : 0.1s
140- - light.turn_on : led
141- - delay : 0.1s
142- - light.turn_off : led
143- - delay : 0.7s
147+ - if :
148+ condition :
149+ lambda : ' return id(setupComplete) == true;'
150+ then :
151+ # Flash twice
152+ - light.turn_on : led
153+ - delay : 0.15s
154+ - light.turn_off : led
155+ - delay : 0.15s
156+ - light.turn_on : led
157+ - delay : 0.15s
158+ - light.turn_off : led
159+ - delay : 1s
144160 # Final state
145161 - if :
146162 condition :
@@ -152,46 +168,57 @@ switch:
152168 name : " Disable Button"
153169 id : disable_button
154170 icon : " mdi:toggle-switch-off-outline"
155- restore_mode : " ${default_state }"
171+ restore_mode : " ${disable_button_default_state }"
156172 optimistic : true
157173 on_turn_on :
158- # Flash thrice
159- - light.turn_off : led
160- - delay : 0.15s
161- - light.turn_on : led
162- - delay : 0.15s
163- - light.turn_off : led
164- - delay : 0.15s
165- - light.turn_on : led
166- - delay : 0.15s
167- - light.turn_off : led
168- - delay : 0.15s
169- - light.turn_on : led
170- - delay : 0.15s
174+ - if :
175+ condition :
176+ lambda : ' return id(setupComplete) == true;'
177+ then :
178+ # Flash thrice
179+ - light.turn_off : led
180+ - delay : 0.15s
181+ - light.turn_on : led
182+ - delay : 0.15s
183+ - light.turn_off : led
184+ - delay : 0.15s
185+ - light.turn_on : led
186+ - delay : 0.15s
187+ - light.turn_off : led
188+ - delay : 0.15s
189+ - light.turn_on : led
190+ - delay : 0.15s
171191 # Final state
172192 - if :
173193 condition :
174- switch.is_off : relay
194+ or :
195+ - switch.is_off : relay
196+ - switch.is_on : disable_led
175197 then :
176198 light.turn_off : led
177199 on_turn_off :
178- # Flash thrice
179- - light.turn_on : led
180- - delay : 0.15s
181- - light.turn_off : led
182- - delay : 0.15s
183- - light.turn_on : led
184- - delay : 0.15s
185- - light.turn_off : led
186- - delay : 0.15s
187- - light.turn_on : led
188- - delay : 0.15s
189- - light.turn_off : led
190- - delay : 0.7s
200+ - if :
201+ condition :
202+ lambda : ' return id(setupComplete) == true;'
203+ then :
204+ # Flash thrice
205+ - light.turn_on : led
206+ - delay : 0.15s
207+ - light.turn_off : led
208+ - delay : 0.15s
209+ - light.turn_on : led
210+ - delay : 0.15s
211+ - light.turn_off : led
212+ - delay : 0.15s
213+ - light.turn_on : led
214+ - delay : 0.15s
215+ - light.turn_off : led
216+ - delay : 1s
191217 # Final state
192218 - if :
193219 condition :
194- switch.is_on : relay
220+ - switch.is_on : relay
221+ - switch.is_off : disable_led
195222 then :
196223 light.turn_on : led
197224
@@ -245,7 +272,7 @@ sensor:
245272 - multiply : 0.001
246273 unit_of_measurement : kWh
247274
248- # Make calibration factor data readable/setable from home assistant
275+ # Make calibration factor data readable/set-able from home assistant
249276number :
250277 - platform : template
251278 name : " Voltage Calibration Factor"
0 commit comments