pool light esp, gas heater esp, HA Overview display

This commit is contained in:
root
2025-09-03 20:53:14 +12:00
parent 540fe186ff
commit a060d819cd
17 changed files with 3436 additions and 37 deletions
Submodule esphome/common/.esphome/external_components/2f2a5be3 added at b2cd0ac45a
+180
View File
@@ -0,0 +1,180 @@
##########################################################################################
# GLOBAL VARIABLES
# https://esphome.io/guides/automations.html?highlight=globals#global-variables
##########################################################################################
globals:
####################################################
# total_energy: cumulative power
# Not restored, so each boot starts fresh at 0.
####################################################
- id: total_energy
type: float
restore_value: yes
initial_value: '0.0'
##########################################################################################
# UART
# https://esphome.io/components/uart/
##########################################################################################
uart:
# Needed for cse776. Set logging baud to 0 also.
id: cse_uart
rx_pin: RX # GPIO3 on ESP8266
baud_rate: 4800
parity: EVEN # CSE7766 requires EVEN
##########################################################################################
# GENERAL COMMON SENSORS
# https://esphome.io/components/sensor/
##########################################################################################
sensor:
#############################################
# CSE7766 POWER SENSOR
# https://esphome.io/components/sensor/cse7766.html
#############################################
- platform: cse7766
id: athom_cse7766
uart_id: cse_uart
current:
name: "Current"
id: plug_current # Added ID so we can reference this in other sensors
icon: mdi:current-ac
filters:
- throttle_average: ${sensor_update_interval}
- lambda: if (x < 0.060) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
on_value_range:
- above: ${current_limit}
then:
- switch.turn_off: relay
voltage:
name: "Voltage"
id: plug_voltage # Added ID so we can reference this in other sensors
icon: mdi:sine-wave
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
power:
name: "Power"
id: power_sensor
icon: mdi:power
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
- lambda: if (x < 3.0) return 0.0; else return x; # For the chip will report less than 3w power when no load is connected
energy:
name: "Energy"
id: energy
icon: mdi:lightning-bolt
unit_of_measurement: kWh
internal: ${hide_energy_sensor}
filters:
- throttle: ${sensor_update_interval}
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
accuracy_decimals: 2
on_value:
then:
- lambda: |-
static float previous_energy_value = 0.0;
float current_energy_value = id(energy).state;
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
id(total_energy_sensor).update();
apparent_power:
name: "Apparent Power"
icon: mdi:power
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
reactive_power:
name: "Reactive Power"
icon: mdi:flash
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
power_factor:
name: "Power Factor"
icon: mdi:percent-outline
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
#############################################
# Total Energy (All Time)
#############################################
- platform: template
name: "Total Energy"
id: total_energy_sensor
unit_of_measurement: kWh
device_class: "energy"
state_class: "total_increasing"
icon: mdi:lightning-bolt
accuracy_decimals: 3
lambda: |-
return id(total_energy);
update_interval: "60s"
#############################################
# Total Daily Energy
# https://esphome.io/components/sensor/total_daily_energy.html
#############################################
- platform: total_daily_energy
name: "Total Daily Energy"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
icon: mdi:hours-24
accuracy_decimals: 3
filters:
- multiply: 0.001
##########################################################################################
# STATUS LED
# https://esphome.io/components/status_led.html
##########################################################################################
status_led:
pin:
number: GPIO13
inverted: True
##########################################################################################
# BINARY SENSORS
# https://esphome.io/components/binary_sensor/
##########################################################################################
binary_sensor:
- platform: gpio
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
id: power_button
name: "Power Button"
disabled_by_default: true
on_multi_click:
- timing:
- ON for at most 1s
- OFF for at least 0.2s
then:
- switch.toggle: relay
#- timing:
# - ON for at least 4s
# then:
# - button.press: Reset
##########################################################################################
# SWITCH COMPONENT
# https://esphome.io/components/switch/
##########################################################################################
switch:
- platform: gpio
name: "Switch"
pin: GPIO12
id: relay
restore_mode: ${relay_restore_mode}
icon: ${power_plug_type}
@@ -0,0 +1,187 @@
##########################################################################################
# GLOBAL VARIABLES
# https://esphome.io/guides/automations.html#global-variables
##########################################################################################
globals:
# total_energy: cumulative power (restored across reboots)
- id: total_energy
type: float
restore_value: yes
initial_value: '0.0'
##########################################################################################
# UART
# https://esphome.io/components/uart/
##########################################################################################
uart:
# Needed for cse776. Set logging baud to 0 also.
id: cse_uart
rx_pin: RX # GPIO3 on ESP8266
baud_rate: 4800
parity: EVEN # CSE7766 requires EVEN
##########################################################################################
# SENSORS
# https://esphome.io/components/sensor/
##########################################################################################
sensor:
#############################################
# CSE7766 POWER SENSOR
# https://esphome.io/components/sensor/cse7766.html
#############################################
- platform: cse7766
id: athom_cse7766
uart_id: cse_uart
current:
name: "Current"
id: plug_current
icon: mdi:current-ac
filters:
- throttle_average: ${sensor_update_interval}
- lambda: if (x < 0.060) return 0.0; else return x;
voltage:
name: "Voltage"
id: plug_voltage
icon: mdi:sine-wave
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
power:
name: "Power"
id: power_sensor
icon: mdi:power
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
- lambda: if (x < 3.0) return 0.0; else return x;
energy:
name: "Energy"
id: energy
icon: mdi:lightning-bolt
unit_of_measurement: kWh
internal: ${hide_energy_sensor}
accuracy_decimals: 2
filters:
- throttle: ${sensor_update_interval}
- multiply: 0.001 # Wh -> kWh
on_value:
then:
- lambda: |-
static float previous_energy_value = 0.0;
float current_energy_value = id(energy).state;
id(total_energy) += current_energy_value - previous_energy_value;
previous_energy_value = current_energy_value;
id(total_energy_sensor).update();
apparent_power:
name: "Apparent Power"
icon: mdi:power
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
reactive_power:
name: "Reactive Power"
icon: mdi:flash
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
power_factor:
name: "Power Factor"
icon: mdi:percent-outline
accuracy_decimals: 2
filters:
- throttle_average: ${sensor_update_interval}
#############################################
# Total Energy (All Time)
#############################################
- platform: template
name: "Total Energy"
id: total_energy_sensor
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
icon: mdi:lightning-bolt
accuracy_decimals: 3
lambda: |-
return id(total_energy);
update_interval: "60s"
#############################################
# Total Daily Energy
# https://esphome.io/components/sensor/total_daily_energy.html
#############################################
- platform: total_daily_energy
name: "Total Daily Energy"
restore: true
power_id: power_sensor
unit_of_measurement: kWh
icon: mdi:hours-24
accuracy_decimals: 3
filters:
- multiply: 0.001
#############################################
# Energy Statistics (Dentra)
#############################################
- platform: energy_statistics
total: total_energy_sensor
energy_today:
name: "Energy Today"
id: total_energy_today
accuracy_decimals: 3
icon: mdi:hours-24
energy_yesterday:
name: "Total Energy Yesterday"
id: total_energy_yesterday
accuracy_decimals: 3
energy_week:
name: "Total Energy Week"
id: total_energy_week
accuracy_decimals: 3
energy_month:
name: "Total Energy Month"
id: total_energy_month
accuracy_decimals: 3
##########################################################################################
# Dentra Components - Adds 'Platform - Energy Statistics'
# https://github.com/dentra/esphome-components/tree/master/components/energy_statistics
##########################################################################################
external_components:
- source: github://dentra/esphome-components
##########################################################################################
# STATUS LED
# https://esphome.io/components/status_led.html
##########################################################################################
status_led:
pin:
number: GPIO13
inverted: true
##########################################################################################
# BINARY SENSORS
# https://esphome.io/components/binary_sensor/
##########################################################################################
binary_sensor:
- platform: gpio
pin:
number: 5
mode: INPUT_PULLUP
inverted: true
id: power_button
name: "Power Button"
disabled_by_default: true
# No relay hardware on this device; leaving the switch section out intentionally.
+3 -3
View File
@@ -53,11 +53,11 @@ wifi:
dns2: ${static_ip_dns2}
use_address: ${local_static_ip_address}
ap: # Details for fallback hotspot in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode
ssid: ${local_device_name} AP
ssid: ${local_device_name}
password: ${fallback_ap_password}
ap_timeout: 10min # Time until it brings up fallback AP. default is 1min
# Allow rapid re-connection to previously connect WiFi SSID, skipping scan of all SSID
fast_connect: "${wifi_fast_connect}"
fast_connect: ${wifi_fast_connect}
# Define dns domain / suffix to add to hostname
domain: "${dns_domain}"
@@ -71,7 +71,7 @@ ota:
- platform: esphome
password: ${local_ota_pass}
version: 2
#- platform: web_server
#- platform: web_server # Uncomment if you want to be able to do OTA with the web interface
#############################################
# Safe Mode