aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKaufHA <[email protected]>2022-11-21 22:03:23 -0700
committerKaufHA <[email protected]>2022-11-21 22:03:23 -0700
commitcf10c3b661bf68d93a62b750f018a216bee6c592 (patch)
tree48837b560e23b24866487ae16f8f1b7621720631
parent8b178f75f9c9248c8d6ddb0549a984bf19d787c9 (diff)
downloadPLF10-cf10c3b661bf68d93a62b750f018a216bee6c592.tar.gz
PLF10-cf10c3b661bf68d93a62b750f018a216bee6c592.zip
factory routine check success
-rw-r--r--kauf-plug-factory.yaml47
-rw-r--r--kauf-plug.yaml2
2 files changed, 35 insertions, 14 deletions
diff --git a/kauf-plug-factory.yaml b/kauf-plug-factory.yaml
index 8347348..52125b7 100644
--- a/kauf-plug-factory.yaml
+++ b/kauf-plug-factory.yaml
@@ -39,38 +39,59 @@ script:
# set scaling factors to expected test load.
# required ranges helps prevent calibration without proper test load.
- lambda: |-
+ uint32_t num_ok = 0;
+
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();
+ num_ok++;
}
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();
+ num_ok++;
}
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();
+ num_ok++;
}
//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();
+ // finish factory test with results argument
+ id(finish_factory_test)->execute(num_ok);
+
+ - id: finish_factory_test
+ parameters:
+ num_ok: int
+ then:
+
+ # blink led to indicate finish test until button is pressed then stay on
+ - while:
+ condition:
+ binary_sensor.is_off: button_in
+ then:
+ - lambda: |-
+ if ( num_ok == 3 ) {
+ auto call = id(blue_led).toggle();
+ call.perform();
+ } else {
+ auto call = id(red_led).toggle();
+ call.perform();
+ }
+ - 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
diff --git a/kauf-plug.yaml b/kauf-plug.yaml
index ab5a800..31dfc79 100644
--- a/kauf-plug.yaml
+++ b/kauf-plug.yaml
@@ -15,7 +15,7 @@ substitutions:
# https://esphome.io/components/esphome.html#esphome-creators-project
project_name: Kauf.PLF10
- project_ver_num: "2.00"
+ project_ver_num: "2.011"
project_ver_let: y
# https://esphome.io/components/switch/gpio.html?highlight=restore_mode