Skip to content

Commit 056a24a

Browse files
committed
Merge branch 'localbytes-push'
2 parents 52a49c5 + 1379afd commit 056a24a

File tree

5 files changed

+96
-71
lines changed

5 files changed

+96
-71
lines changed

.github/workflows/publish-esphome.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ jobs:
4949
outputs:
5050
esphome-version: ${{ steps.esphome-build.outputs.esphome-version }}
5151
steps:
52-
- uses: actions/checkout@v3.5.3
53-
- uses: esphome/build-action@v1.5.2
52+
- uses: actions/checkout@v4.2.0
53+
- uses: esphome/build-action@v3.1.0
5454
id: esphome-build
5555
with:
5656
yaml_file: ${{ matrix.file }}
@@ -69,7 +69,7 @@ jobs:
6969
runs-on: ubuntu-latest
7070
needs: [build]
7171
steps:
72-
- uses: actions/checkout@v3.5.3
72+
- uses: actions/checkout@v4.2.0
7373
- uses: actions/download-artifact@v3.0.2
7474
with:
7575
path: output
@@ -82,8 +82,8 @@ jobs:
8282
- run: cp -R static/* output
8383

8484
- name: Deploy 🚀
85-
uses: JamesIves/github-pages-deploy-action@v4.4.1
85+
uses: JamesIves/github-pages-deploy-action@v4.6.8
8686
with:
8787
branch: gh-pages
8888
folder: output
89-
clean: ${{ inputs.clean }}
89+
clean: ${{ inputs.clean }}

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ name: Build and Publish ESPHome firmware and website
22

33
on:
44
push:
5-
branches:
6-
- main
5+
6+
permissions:
7+
contents: write
78

89
jobs:
910
build:

localbytes-plug-pm-factory.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,10 @@ esphome:
1919
- lambda: |-
2020
id(power_monitor).set_change_mode_every(4);
2121
id(power_monitor).set_update_interval(250);
22-
- while:
23-
condition:
24-
lambda: "return isnan(id(voltage).raw_state) || isnan(id(power).raw_state) || isnan(id(current).raw_state)
25-
|| id(voltage).raw_state < 10 || id(power).raw_state < 10 || id(power).raw_state < 0.1;"
26-
then:
27-
- logger.log:
28-
level: "DEBUG"
29-
format: "Waiting for power"
30-
- delay: 500ms
3122
- logger.log:
3223
level: INFO
3324
format: "Plug calibration start"
34-
- delay: 2s
25+
- delay: 4s
3526
- lambda: |-
3627
id(voltage_multiply) = (230 / id(voltage).raw_state);
3728
ESP_LOGI("custom", "Voltage %f -- %f",id(voltage).raw_state,id(voltage_multiply));

localbytes-plug-pm.yaml

Lines changed: 81 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ packages:
33

44
esphome:
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

1217
wifi:
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+
6777
binary_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
249276
number:
250277
- platform: template
251278
name: "Voltage Calibration Factor"

minimal.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ substitutions:
1010
# Options: `RESTORE_DEFAULT_OFF`, `RESTORE_DEFAULT_ON`, `ALWAYS_ON` & `ALWAYS_OFF`
1111
default_state: "RESTORE_DEFAULT_OFF"
1212

13+
# Default state of the "disable led" virtual switch
14+
disable_led_default_state: "RESTORE_DEFAULT_OFF"
15+
16+
# Default state of the "disable button"/child-lock virtual switch
17+
disable_button_default_state: "RESTORE_DEFAULT_OFF"
18+
1319
esphome:
1420
name: "${name}"
1521
friendly_name: "${friendly_name}"

0 commit comments

Comments
 (0)