blob: 84e46e0a89b60e3110f6bae8e7b831ebdadd2440 (
plain)
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
|
packages:
kauf_plug_update:
url: https://github.com/KaufHA/PLF10
files: config-update/kauf-plug-update.yaml
refresh: 0s
preferences:
flash_write_interval: 3s
esphome:
# overwrite project for different letter suffix
project:
name: "kauf.plf10"
version: "1.85(f)" # 'f' stands for factory image
on_boot:
then:
# little sequence so factory can confirm firwmare is working.
- if:
condition:
lambda: 'return id(first_boot);'
then:
# get AP going ASAP
- lambda: 'wifi_wificomponent->set_ap_timeout(1);'
# disable button toggling relay
- select.set:
id: select_button
option: "Disabled"
# turn on relay to draw current
- switch.turn_on: relay
- delay: 1s
- switch.turn_off: blue_led
# wait until button is pressed, then turn on led
- while:
condition:
binary_sensor.is_off: button_in
then:
- switch.turn_off: blue_led
- delay: 50ms
- while:
condition:
binary_sensor.is_on: button_in
then:
- switch.turn_on: blue_led
- delay: 50ms
# give it some time to see if a crash occurs with both AP and relay on
- delay: 8s
# test passed, clear first_boot variable so we don't run this again
- globals.set:
id: first_boot
value: 'false'
# re-enable button toggling relay
- select.set:
id: select_button
option: "Enabled"
# delay time to save above changes
- delay: 3s
# blink blue led to indicate pass test until button is pressed then stay on
- while:
condition:
binary_sensor.is_off: button_in
then:
- switch.toggle: blue_led
- delay: 100ms
- while:
condition:
binary_sensor.is_on: button_in
then:
- switch.turn_on: blue_led
- delay: 50ms
globals:
- id: first_boot # used to run routine at factory to confirm
type: bool # correct firwmare is running.
restore_value: yes
initial_value: 'true'
|