From d7a11165573e0421cfb1b44a7e14f1f66473538d Mon Sep 17 00:00:00 2001 From: longranger Date: Sat, 11 May 2024 07:20:17 -0700 Subject: [PATCH] New outside fountain relay. --- _data/fountain_outside.yaml | 207 ++++++++++++++++++------------------ 1 file changed, 103 insertions(+), 104 deletions(-) diff --git a/_data/fountain_outside.yaml b/_data/fountain_outside.yaml index ce1b864..e9dd415 100644 --- a/_data/fountain_outside.yaml +++ b/_data/fountain_outside.yaml @@ -3,120 +3,119 @@ substitutions: dn: fountain_outside friendly_name: Fountain Outside device_description: Energy Monitoring Smart Plug with button, blue LED, and red LED. + # Higher value gives lower watt readout + current_res: "0.001" + # Lower value gives lower voltage readout + voltage_div: "770" <<: !include .common.yaml -<<: !include .esp8266.yaml <<: !include .wifi-oss.yaml -# Enable time component for use by daily power sensor -time: - - platform: homeassistant - id: homeassistant_time - -binary_sensor: - - platform: gpio - pin: - number: GPIO1 - mode: INPUT_PULLUP - inverted: True - name: ${friendly_name} button - on_multi_click: - - timing: - - ON for at most 1s - - OFF for at most 1s - - ON for at most 1s - - OFF for at least 0.2s - then: - - logger.log: "Double Clicked" - - switch.toggle: relay2 - - timing: - - ON for 1s to 2s - - OFF for at least 0.5s - then: - - logger.log: "Single Long Clicked" - - timing: - - ON for at most 1s - - OFF for at least 0.5s - then: - - logger.log: "Single Short Clicked" - - switch.toggle: relay1 +esphome: + name: "${dn}" + platform: ESP32 + board: esp-wrover-kit switch: - platform: gpio - name: ${friendly_name} relay - pin: GPIO12 + name: ${friendly_name} Pump + pin: + number: GPIO15 + inverted: false id: relay1 + on_turn_on: + - light.turn_on: relay1_led + on_turn_off: + - light.turn_off: relay1_led - platform: gpio - name: ${friendly_name} Light relay - pin: GPIO14 + name: ${friendly_name} Light + pin: + number: GPIO32 + inverted: false id: relay2 + on_turn_on: + - light.turn_on: relay2_led + on_turn_off: + - light.turn_off: relay2_led + - platform: restart + name: ${friendly_name} Restart + +output: + - platform: gpio + pin: GPIO19 + inverted: True + id: relay1_led_gpio + - platform: gpio + pin: GPIO16 + inverted: True + id: relay2_led_gpio + +light: + - platform: binary + name: "Relay1 LED" + id: relay1_led + internal: true + output: relay1_led_gpio + - platform: binary + name: "Relay2 LED" + id: relay2_led + internal: true + output: relay2_led_gpio + +sensor: + - platform: adc + pin: GPIO34 + name: "${friendly_name} LUX" + update_interval: 10s + attenuation: 11db + - platform: hlw8012 + sel_pin: + number: GPIO25 + inverted: true + cf_pin: GPIO27 + cf1_pin: GPIO26 + current_resistor: ${current_res} + voltage_divider: ${voltage_div} + change_mode_every: 3 + update_interval: 3s + current: + name: "${friendly_name} Amps" + unit_of_measurement: A + accuracy_decimals: 2 + voltage: + name: "${friendly_name} Volts" + unit_of_measurement: V + accuracy_decimals: 1 + power: + name: "${friendly_name} Watts" + unit_of_measurement: W + accuracy_decimals: 1 + filters: + - calibrate_linear: + - 0.0 -> 0.0 + - 134 -> 58 + +binary_sensor: + - platform: gpio + internal: true + pin: + number: GPIO18 + mode: INPUT_PULLDOWN + inverted: True + name: ${friendly_name} Button1 + on_press: + - switch.toggle: relay1 + - platform: gpio + internal: true + pin: + number: GPIO17 + mode: INPUT_PULLDOWN + inverted: True + name: ${friendly_name} Button2 + on_press: + - switch.toggle: relay2 status_led: pin: - number: GPIO3 - # inverted: yes - -sensor: - - platform: wifi_signal - name: ${friendly_name} WiFi signal - update_interval: 60s - - - platform: uptime - name: ${friendly_name} uptime - -# Reports the Current, Voltage, and Power used by the plugged-in device (not counting this plug's own usage of about 0.7W/0.02A, so subtract those when calibrating with this plugged into a Kill-A-Watt type meter) - - platform: hlw8012 - sel_pin: - number: GPIO13 - inverted: True - cf_pin: GPIO4 - cf1_pin: GPIO5 - current_resistor: 0.001 #The value of the shunt resistor for current measurement. Defaults to the Sonoff POW’s value 0.001 ohm. Verified on https://fccid.io/2AKBP-X10S/Internal-Photos/X10S-Int-photo-4308983 that we use "R001" = 0.001 ohm - voltage_divider: 2351 #The value of the voltage divider on the board as (R_upstream + R_downstream) / R_downstream. Defaults to the Sonoff POW’s value 2351. From the pic we use 2x "125" = 2x 1.2Mohm for R_upstream and "102" = 1kohm for R_downstream, so (1,200,000+1,200,000+1,000)/1,000 = 2401 - # but those don't fix the measurement values, probably because we actually have a BL0937 chip instead of a HLW8012, (and part variance aswell) so we have to manually calibrate with a known load or a load and a Kill-A-Watt type meter. My values used below will only be +/-10% of yours I think. - # The comments about the voltage divider were taken from the AWP04L template. I was unable to verify the voltage divider in the Aoycocr X10S plug. - power: - name: ${friendly_name} Power - unit_of_measurement: W - id: wattage - filters: - - calibrate_linear: - # Map 0.0 (from sensor) to 0.0 (true value) - - 0.0 -> 0.0 #Need to keep 0 mapped to 0 for when connected device is not drawing any power - - 1379.1 -> 200.0 # Tested outdoor fountain pump via Kill-A-Watt - - 2816.9 -> 411.0 # Tested blow-dryer low via Kill-A-Watt - - 9250.6 -> 1341.0 # Tested water boiler via Kill-A-Watt - - 10736.7 -> 1562.0 # Tested blow-dryer high via Kill-A-Watt - current: - name: ${friendly_name} Current - unit_of_measurement: A - filters: - - calibrate_linear: - # Map 0.0 (from sensor) to 0.0 (true value) - - 0.0 -> 0.0 #Need to keep 0 mapped to 0 for when connected device is not drawing any power - - 2.07 -> 1.67 # Tested outdoor fountain pump via Kill-A-Watt - - 4.18 -> 3.41 # Tested blow-dryer low via Kill-A-Watt - - 14.37 -> 11.64 # Tested water boiler via Kill-A-Watt - - 16.26 -> 13.12 # Tested blow-dryer high via Kill-A-Watt - voltage: - name: ${friendly_name} Voltage - unit_of_measurement: V - filters: - - calibrate_linear: - # Map 0.0 (from sensor) to 0.0 (true value) - - 0.0 -> 0.0 - - 355.9 -> 120.6 #Tested using a Kill-A-Watt meter, value while connected LED bulb was on - # change_mode_every: 3 # 1 - Skips first reading after each change, so this will double the update interval. Default 8 - # update_interval: 3s # 10s - 20 second effective update rate for Power, 40 second for Current and Voltage. Default 60s - -# Reports the total Power so-far each day, resets at midnight, see 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 - -text_sensor: - - platform: version - name: "Fountain 1 ESPHome version" \ No newline at end of file + number: GPIO5 + inverted: true \ No newline at end of file