diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | kauf-plug-update.yaml | 57 | ||||
-rw-r--r-- | kauf-plug.yaml | 45 |
3 files changed, 85 insertions, 18 deletions
@@ -6,4 +6,3 @@ kauf-plug-test.yaml kauf-plug-test-2.yaml kauf-plug-old.yaml kauf-plug-dev.yaml - diff --git a/kauf-plug-update.yaml b/kauf-plug-update.yaml index 30ed5a9..8e75756 100644 --- a/kauf-plug-update.yaml +++ b/kauf-plug-update.yaml @@ -24,6 +24,16 @@ esphome: # with any other on_boot scripts. - script.execute: on_boot_wifi +external_components: +# - source: +# type: git +# url: https://github.com/KaufHA/common +# # ref: v2022.06.21 +# refresh: 0s + - source: + type: local + path: dev-common + globals: - id: force_ap @@ -87,9 +97,54 @@ script: wifi.connected - globals.set: # clear global so ap doesn't come back up next time id: force_ap - value: 'false' + value: 'false' # set ap timeout to max 32 bit value in milliseconds. About 3.5 weeks. - lambda: |- ESP_LOGD("KAUF on_boot","------------------->>>>>>>>>>>>>>>>> wifi connected, cranking ap timeout back up"); wifi_wificomponent->set_ap_timeout(2147483647); + +# select: +# # default light state on boot +# - platform: template +# name: $friendly_name Power On State +# id: select_boot_state +# optimistic: true +# options: +# - "Restore Power Off State" +# - "Always On" +# - "Always Off" +# initial_option: Restore Power Off State +# restore_value: true +# icon: mdi:restart-alert +# on_value: +# - lambda: |- +# if ( x == "Always On" ) { +# // disable saving any more values in the relay flash address +# relay->set_restore_mode(esphome::gpio::GPIO_SWITCH_ALWAYS_ON); + +# // save a "1" in the relay flash address so that gets restored next time +# relay->force_save(true); +# } +# else if ( x == "Always Off" ) { +# // disable saving any more values in the relay flash address +# relay->set_restore_mode(esphome::gpio::GPIO_SWITCH_ALWAYS_ON); + +# // save a "0" in the relay flash address so that gets restored next time +# relay->force_save(false); +# } +# else +# relay->set_restore_mode(esphome::gpio::GPIO_SWITCH_$sub_restore_mode); +# //relay->write_state(id(relay)); +# - script.execute: script_save_changes +# - delay: 5s + +# # always go to a restoring mode after boot, we already got what we wanted out of the boot state, +# # this way the current state will continue to be saved no matter the setting. +# - lambda: relay->set_restore_mode(esphome::gpio::GPIO_SWITCH_RESTORE_DEFAULT_ON); + +# entity_category: config +# forced_hash: 3222171394 +# forced_addr: 74 +# global_addr: global_forced_addr + diff --git a/kauf-plug.yaml b/kauf-plug.yaml index ab8ac55..47ef5ab 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: "1.972" + project_ver_num: "1.973" project_ver_let: y # https://esphome.io/components/switch/gpio.html?highlight=restore_mode @@ -50,6 +50,7 @@ substitutions: # incorporate this file as a package to get all the updates we release. current_resistor_val: "0.001" voltage_divider_val: "2401" + sub_hlw_model: HLW8012 power_cal_val1_in: "0.0" power_cal_val1_out: "0.0" power_cal_val2_in: "333.8" @@ -70,6 +71,19 @@ substitutions: sub_update_interval: 10s sub_initial_mode: CURRENT + # GPIO definitions + sub_pm_sel_pin: GPIO12 + sub_pm_cf_pin: GPIO5 + sub_pm_cf1_pin: GPIO14 + sub_button_pin: GPIO13 + sub_blue_led_pin: GPIO2 + sub_red_led_pin: GPIO0 + sub_relay_pin: GPIO4 + + # debounce specifications + sub_default_debounce: "100" + sub_min_debounce: "50" + # https://esphome.io/components/esp8266.html esp8266: @@ -169,7 +183,7 @@ binary_sensor: id: button_in name: $friendly_name Button pin: - number: GPIO13 + number: $sub_button_pin mode: input: true pullup: true @@ -211,7 +225,6 @@ script: - id: script_set_power_leds then: - lambda: |- - auto call = id(blue_led).make_call(); // if blue led follows power status @@ -242,7 +255,6 @@ script: then: - lambda: |- - // turn on blue LED if configured for error status if ( (id(select_bled).state == "Error Status") || (id(select_bled).state == "Error and Power") || @@ -264,7 +276,6 @@ script: - delay: 350ms - lambda: |- - // turn off blue LED if configured for error status if ( (id(select_bled).state == "Error Status") || (id(select_bled).state == "Error and Power") || @@ -320,13 +331,13 @@ script: output: - platform: esp8266_pwm id: blue_led_pwm - frequency: 1000 Hz - pin: GPIO2 + frequency: 200 Hz + pin: $sub_blue_led_pin inverted: true - platform: esp8266_pwm id: red_led_pwm - frequency: 1000 Hz - pin: GPIO0 + frequency: 200 Hz + pin: $sub_red_led_pin inverted: true @@ -373,7 +384,7 @@ switch: - platform: gpio id: relay name: $friendly_name - pin: GPIO4 + pin: $sub_relay_pin entity_category: '' forced_hash: 41191675 forced_addr: 2 @@ -434,10 +445,10 @@ sensor: # Power monitoring sensors output to Home Assistant - platform: hlw8012 id: hlw_main sel_pin: - number: GPIO12 + number: $sub_pm_sel_pin inverted: True - cf_pin: GPIO5 - cf1_pin: GPIO14 + cf_pin: $sub_pm_cf_pin + cf1_pin: $sub_pm_cf1_pin current_resistor: $current_resistor_val voltage_divider: $voltage_divider_val @@ -445,6 +456,8 @@ sensor: # Power monitoring sensors output to Home Assistant update_interval: $sub_update_interval initial_mode: $sub_initial_mode + model: $sub_hlw_model + power: name: ${friendly_name} Power unit_of_measurement: W @@ -595,10 +608,10 @@ number: # used as a threshold for whether the plugged-in devices is running - platform: template name: ${friendly_name} Debounce Time - min_value: 50 + min_value: $sub_min_debounce max_value: 2000 step: 1 - initial_value: 100 + initial_value: $sub_default_debounce id: number_debounce entity_category: config optimistic: true @@ -704,7 +717,7 @@ select: global_addr: global_forced_addr set_action: - script.execute: script_save_changes - + - platform: template name: $friendly_name Blue LED Config |