aboutsummaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorKaufHA <[email protected]>2024-05-14 13:32:23 -0700
committerKaufHA <[email protected]>2024-05-14 13:32:23 -0700
commitcefc8013f6e9b9545bfb74ba6d5e56cceeab5429 (patch)
tree50671898fc136f44f008fa295ca2c5c6245fabcb /config
parent5bc4d2c50e5d683b3eb994e338deb0beab65d6b2 (diff)
downloadPLF12-cefc8013f6e9b9545bfb74ba6d5e56cceeab5429.tar.gz
PLF12-cefc8013f6e9b9545bfb74ba6d5e56cceeab5429.zip
move configs to subdir
Diffstat (limited to 'config')
-rw-r--r--config/kauf-plf12-base.yaml37
-rw-r--r--config/kauf-plf12-factory.yaml108
-rw-r--r--config/kauf-plf12-lite.yaml3
-rw-r--r--config/kauf-plf12-minimal.yaml203
-rw-r--r--config/kauf-plf12-update.yaml6
5 files changed, 357 insertions, 0 deletions
diff --git a/config/kauf-plf12-base.yaml b/config/kauf-plf12-base.yaml
new file mode 100644
index 0000000..b2bcc0b
--- /dev/null
+++ b/config/kauf-plf12-base.yaml
@@ -0,0 +1,37 @@
+# this file contains anything that needs to be changed for PLF12 relative to PLF10.
+
+substitutions:
+ project_name: Kauf.PLF12
+
+ # power monitoring configuration
+ voltage_divider_val: "2001"
+ sub_hlw_model: BL0937
+ power_cal_val2_in: "879.4"
+ power_cal_val2_out: "750"
+ current_cal_val2_in: "6.8"
+ current_cal_val2_out: "3.5"
+ voltage_cal_val2_in: "132.7"
+ voltage_cal_val2_out: "119.1"
+
+ # GPIO definitions
+ sub_red_led_pin: GPIO1
+ sub_button_pin: GPIO3
+ sub_pm_cf_pin: GPIO4
+ sub_pm_cf1_pin: GPIO5
+ sub_blue_led_pin: GPIO12
+ sub_relay_pin: GPIO13
+ sub_pm_sel_pin: GPIO14
+
+ # debounce specifications
+ sub_default_debounce: "20"
+ sub_min_debounce: "10"
+
+ sub_default_scale_power: "87"
+ sub_default_scale_current: "162"
+ sub_default_scale_voltage: "85"
+
+ sub_early_publish_absolute: "4.05" # for PLF12, 1w is approximately 1.35. 4.05 is approximately 3w.
+
+
+logger:
+ baud_rate: 0
diff --git a/config/kauf-plf12-factory.yaml b/config/kauf-plf12-factory.yaml
new file mode 100644
index 0000000..a40150c
--- /dev/null
+++ b/config/kauf-plf12-factory.yaml
@@ -0,0 +1,108 @@
+substitutions:
+ project_ver_let: "f"
+
+ sub_update_interval: 2s
+ sub_pm_initial_option: YAML Configured ($sub_update_interval)
+
+
+packages:
+ kauf_plug_update: !include kauf-plf12-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);'
+
+ # reset scaling factors to 100
+ - number.set:
+ id: scale_power
+ value: 100
+ - number.set:
+ id: scale_current
+ value: 100
+ - number.set:
+ id: scale_voltage
+ value: 100
+
+ # turn on relay
+ - switch.turn_on: relay
+ - delay: 1s
+ - switch.turn_off: blue_led
+
+ - delay: 12s
+
+ # 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: |-
+ uint32_t num_ok = 0;
+
+ if ( (id(wattage).state > 10) && (id(wattage).state < 100) ) {
+ 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.01) && (id(current).state < 5.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 > 20) && (id(voltage).state < 250) ) {
+ 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;
+
+ // 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 ) { id(blue_led).toggle(); }
+ else { id(red_led).toggle(); }
+ - delay: 100ms
+
+ # set power monitoring mode to lower frequency default
+ - select.set:
+ id: select_monitor_interval
+ option: "10s"
+ - lambda: global_preferences->sync();
+
+
+globals:
+ - id: first_boot # used to run test routine at factory
+ type: bool
+ restore_value: yes
+ initial_value: 'true'
diff --git a/config/kauf-plf12-lite.yaml b/config/kauf-plf12-lite.yaml
new file mode 100644
index 0000000..a0766b9
--- /dev/null
+++ b/config/kauf-plf12-lite.yaml
@@ -0,0 +1,3 @@
+packages:
+ Kauf.PLF10: github://KaufHA/PLF10/kauf-plug-lite.yaml
+ Kauf.PLF12-Base: github://KaufHA/PLF12/kauf-plf12-base.yaml
diff --git a/config/kauf-plf12-minimal.yaml b/config/kauf-plf12-minimal.yaml
new file mode 100644
index 0000000..48dcd3f
--- /dev/null
+++ b/config/kauf-plf12-minimal.yaml
@@ -0,0 +1,203 @@
+# https://esphome.io/guides/configuration-types.html#substitutions
+substitutions:
+
+ name: kauf-plug # **** CHANGE DEVICE NAME TO SOMETHING UNIQUE PER DEVICE. RENAME YAML FILE TO SAME NAME. ****
+ # **** USE DASHES (-) INSTEAD OF SPACES OR UNDERSCORE (_). USE ONLY LOWER CASE LETTERS. ****
+
+ friendly_name: Kauf Plug # **** CHANGE FRIENDLY NAME TO SOMETHING UNIQUE PER DEVICE ****
+
+ # substitutions for power monitoring calibration. Allows end users to change calibration in their yaml and still
+ # incorporate this file as a package to get all the updates we release.
+ voltage_divider_val: "2001"
+ sub_hlw_model: BL0937
+ current_resistor_val: "0.001"
+ power_cal_val1_in: "0.0"
+ power_cal_val1_out: "0.0"
+ power_cal_val2_in: "879.4"
+ power_cal_val2_out: "750"
+ current_cal_val1_in: "0.0"
+ current_cal_val1_out: "0.0"
+ current_cal_val2_in: "6.8"
+ current_cal_val2_out: "3.5"
+ voltage_cal_val1_in: "0.0"
+ voltage_cal_val1_out: "0.0"
+ voltage_cal_val2_in: "132.7"
+ voltage_cal_val2_out: "119.1"
+
+ # set power monitoring mode in yaml, selecting the "yaml_configured" option in the select entity will cause these
+ # values to be used after next reboot.
+ # https://esphome.io/components/sensor/hlw8012.html#configuration-variables
+ sub_change_mode_every: "1"
+ sub_update_interval: 10s
+ sub_initial_mode: CURRENT
+
+ # GPIO definitions
+ sub_red_led_pin: GPIO1
+ sub_button_pin: GPIO3
+ sub_pm_cf_pin: GPIO4
+ sub_pm_cf1_pin: GPIO5
+ sub_blue_led_pin: GPIO12
+ sub_relay_pin: GPIO13
+ sub_pm_sel_pin: GPIO14
+
+# https://esphome.io/components/esphome.html
+esphome:
+
+ name: $name
+
+ # https://esphome.io/components/esphome.html#esphome-creators-project
+ project:
+ name: "Kauf.PLF12"
+ version: "2.02(m)"
+
+
+# https://esphome.io/components/esp8266.html
+esp8266:
+ board: esp01_1m
+ restore_from_flash: true
+ early_pin_init: false
+
+
+# https://esphome.io/components/wifi.html
+wifi:
+
+ # **** ENTER WI-FI CREDENTIALS HERE, USING SECRETS.YAML RECOMMENDED ****
+ ssid: initial_ap # !secret my_wifi_ssid
+ password: asdfasdfasdfasdf # !secret my_wifi_pass
+
+ # default is 20, 17 is recommended.
+ output_power: 17
+
+ # using fast_connect as default since it is required for hidden networks.
+ # feel free to change or override.
+ fast_connect: true
+
+ ap:
+
+
+captive_portal: # https://esphome.io/components/captive_portal.html
+web_server: # https://esphome.io/components/web_server.html
+logger: # https://esphome.io/components/logger.html
+api: # https://esphome.io/components/api.html
+ota: # https://esphome.io/components/ota.html
+
+
+# https://esphome.io/components/status_led.html
+# red led, blink when not connected to wifi or Home Assistant
+status_led:
+ pin:
+ number: $sub_red_led_pin
+ inverted: true
+
+
+# https://esphome.io/components/binary_sensor/index.html
+binary_sensor:
+
+ # button input toggles relay and thereby blue led
+ # https://esphome.io/components/binary_sensor/gpio.html
+ - platform: gpio
+ id: button
+ name: $friendly_name Button
+ pin:
+ number: $sub_button_pin
+ mode:
+ input: true
+ pullup: true
+ inverted: true
+
+ filters:
+ - delayed_on: 50ms
+
+ on_press:
+ then:
+ switch.toggle: relay
+
+
+# https://esphome.io/components/switch/index.html
+# https://esphome.io/components/switch/gpio.html
+switch:
+
+ # blue LED follows relay power state
+ - platform: gpio
+ id: blue_led
+ pin:
+ number: $sub_blue_led_pin
+ inverted: true
+ restore_mode: RESTORE_DEFAULT_ON
+
+ # relay output
+ - platform: gpio
+ id: relay
+ name: $friendly_name
+ pin: $sub_relay_pin
+ restore_mode: RESTORE_DEFAULT_ON
+
+ # automatically make blue led equal relay state
+ on_turn_on:
+ - switch.turn_on: blue_led
+ on_turn_off:
+ - switch.turn_off: blue_led
+
+
+# clock input from Home Assistant used to calculate total daily energy
+# https://esphome.io/components/time.html#home-assistant-time-source
+time:
+ - platform: homeassistant
+ id: homeassistant_time
+
+
+# https://esphome.io/components/sensor/index.html
+sensor: # Power monitoring sensors output to Home Assistant
+
+ # https://esphome.io/components/sensor/hlw8012.html
+ - platform: hlw8012
+ id: hlw_main
+ sel_pin:
+ number: $sub_pm_sel_pin
+ inverted: True
+ cf_pin: $sub_pm_cf_pin
+ cf1_pin: $sub_pm_cf1_pin
+ current_resistor: $current_resistor_val
+ voltage_divider: $voltage_divider_val
+
+ change_mode_every: $sub_change_mode_every
+ update_interval: $sub_update_interval
+ initial_mode: $sub_initial_mode
+
+ model: $sub_hlw_model
+
+ power:
+ name: ${friendly_name} Power
+ unit_of_measurement: W
+ id: wattage
+ filters:
+ - calibrate_linear:
+ - $power_cal_val1_in -> $power_cal_val1_out
+ - $power_cal_val2_in -> $power_cal_val2_out
+
+ current:
+ name: ${friendly_name} Current
+ unit_of_measurement: A
+ id: current
+ filters:
+ - calibrate_linear:
+ - $current_cal_val1_in -> $current_cal_val1_out
+ - $current_cal_val2_in -> $current_cal_val2_out
+
+ voltage:
+ name: ${friendly_name} Voltage
+ unit_of_measurement: V
+ id: voltage
+ filters:
+ - calibrate_linear:
+ - $voltage_cal_val1_in -> $voltage_cal_val1_out
+ - $voltage_cal_val2_in -> $voltage_cal_val2_out
+
+ # Reports the total Power so-far each day, resets at midnight
+ # https://esphome.io/components/sensor/total_daily_energy.html
+ - platform: total_daily_energy
+ name: ${friendly_name} Total Daily Energy
+ power_id: wattage
+ filters:
+ - multiply: 0.001 ## convert Wh to kWh
+ unit_of_measurement: kWh
diff --git a/config/kauf-plf12-update.yaml b/config/kauf-plf12-update.yaml
new file mode 100644
index 0000000..b760802
--- /dev/null
+++ b/config/kauf-plf12-update.yaml
@@ -0,0 +1,6 @@
+packages:
+ kauf.plf10-update: !include ../PLF10/kauf-plug-update.yaml
+ kauf.plf12-base: !include kauf-plf12-base.yaml
+
+dashboard_import:
+ package_import_url: github://KaufHA/PLF12/kauf-plf12.yaml