blob: 8347348945fa997559b0615f71fe6be621bba8ad (
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
|
substitutions:
project_ver_let: "f"
select_monitor_mode_initial_option: " 2s P / 8s V,I"
packages:
kauf_plug_update: !include kauf-plug-update.yaml
esphome:
on_boot:
then:
- script.execute: script_factory_test
script:
- id: script_factory_test
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);'
# turn on relay
- switch.turn_on: relay
- delay: 1s
- light.turn_off: blue_led
- delay: 16s
# ensure all 3 values are reported
- wait_until:
lambda: return(!std::isnan(id(wattage).state) && !std::isnan(id(current).state) && !std::isnan(id(voltage).state));
# set scaling factors to expected test load.
# required ranges helps prevent calibration without proper test load.
- lambda: |-
if ( (id(wattage).state > 20) && (id(wattage).state < 40) ) {
auto call = id(scale_power).make_call();
call.set_value(ceil((10.0f*100.0f*26.800f) / id(wattage).state) / 10.0f);
call.perform();
}
if ( (id(current).state > 0.05) && (id(current).state < 1.0) ) {
auto call = id(scale_current).make_call();
call.set_value(ceil((10.0f*100.0f*0.226f) / id(current).state) / 10.0f);
call.perform();
}
if ( (id(voltage).state > 90) && (id(voltage).state < 150) ) {
auto call = id(scale_voltage).make_call();
call.set_value(ceil((10.0f*100.0f*120.0f) / id(voltage).state) / 10.0f);
call.perform();
}
//test passed, clear first_boot variable so we don't run this again
id(first_boot) = false;
# blink blue led to indicate pass test until button is pressed then stay on
- while:
condition:
binary_sensor.is_off: button_in
then:
- light.toggle: blue_led
- delay: 100ms
# set power monitoring mode to lower frequency default
- select.set:
id: select_monitor_mode
option: "10s P / 40s V,I"
- lambda: global_preferences->sync();
globals:
- id: first_boot # used to run test routine at factory
type: bool
restore_value: yes
initial_value: 'true'
|