New outside fountain relay.

This commit is contained in:
2024-05-11 07:20:17 -07:00
parent f7dbd54180
commit d7a1116557

View File

@@ -3,120 +3,119 @@ substitutions:
dn: fountain_outside dn: fountain_outside
friendly_name: Fountain Outside friendly_name: Fountain Outside
device_description: Energy Monitoring Smart Plug with button, blue LED, and red LED. 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 .common.yaml
<<: !include .esp8266.yaml
<<: !include .wifi-oss.yaml <<: !include .wifi-oss.yaml
# Enable time component for use by daily power sensor esphome:
time: name: "${dn}"
- platform: homeassistant platform: ESP32
id: homeassistant_time board: esp-wrover-kit
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
switch: switch:
- platform: gpio - platform: gpio
name: ${friendly_name} relay name: ${friendly_name} Pump
pin: GPIO12 pin:
number: GPIO15
inverted: false
id: relay1 id: relay1
on_turn_on:
- light.turn_on: relay1_led
on_turn_off:
- light.turn_off: relay1_led
- platform: gpio - platform: gpio
name: ${friendly_name} Light relay name: ${friendly_name} Light
pin: GPIO14 pin:
number: GPIO32
inverted: false
id: relay2 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: status_led:
pin: pin:
number: GPIO3 number: GPIO5
# inverted: yes inverted: true
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 POWs 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 POWs 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"