aboutsummaryrefslogtreecommitdiffhomepage
path: root/kauf-plug-factory.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'kauf-plug-factory.yaml')
-rw-r--r--kauf-plug-factory.yaml69
1 files changed, 34 insertions, 35 deletions
diff --git a/kauf-plug-factory.yaml b/kauf-plug-factory.yaml
index f71129a..3cdf9f3 100644
--- a/kauf-plug-factory.yaml
+++ b/kauf-plug-factory.yaml
@@ -1,5 +1,6 @@
substitutions:
project_ver_let: "f"
+ select_monitor_mode_initial_option: " 2s P / 8s V,I"
packages:
@@ -24,45 +25,38 @@ script:
# get AP going ASAP
- lambda: 'wifi_wificomponent->set_ap_timeout(1);'
- # disable button toggling relay
- - select.set:
- id: select_button
- option: "Don't Toggle"
-
- # turn on relay to draw current
+ # turn on relay
- switch.turn_on: relay
- delay: 1s
- light.turn_off: blue_led
- # wait until button is pressed, then turn on led
- - while:
- condition:
- binary_sensor.is_off: button_in
- then:
- - light.turn_off: blue_led
- - delay: 50ms
- - while:
- condition:
- binary_sensor.is_on: button_in
- then:
- - light.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: "Toggle on Release"
-
- # delay time to save above changes
- - delay: 3s
+ - 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 < 33) ) {
+ 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:
@@ -72,6 +66,11 @@ script:
- 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