# 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. 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" power_cal_val2_out: "60" current_cal_val1_in: "0.0" current_cal_val1_out: "0.0" current_cal_val2_in: "0.6" current_cal_val2_out: "0.515" voltage_cal_val1_in: "0.0" voltage_cal_val1_out: "0.0" voltage_cal_val2_in: "302.1" voltage_cal_val2_out: "117.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_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 # https://esphome.io/components/esphome.html esphome: name: $name # https://esphome.io/components/esphome.html#esphome-creators-project project: name: "Kauf.PLF10" 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: GPIO0 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: GPIO13 mode: input: true pullup: true inverted: true filters: - delayed_on: 100ms 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: GPIO2 inverted: true restore_mode: RESTORE_DEFAULT_ON # relay output - platform: gpio id: relay name: $friendly_name pin: GPIO4 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