Edit esp-laundrywashpow.yaml
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-laundrywashpow.yaml
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.2 2026-07-12 Added cumulative Load Energy integration sensor
|
||||
# Added seven-day maximum power sensor
|
||||
# Maximum power resets after 168 powered hours
|
||||
# V1.1 2026-03-11 Updated yaml to zorruno layout V1.1
|
||||
# V1.0 2025-03-28 Initial Version
|
||||
#:########################################################################################:#
|
||||
@@ -20,7 +23,18 @@
|
||||
# - Reference: https://devices.esphome.io/devices/Sonoff-POW-R1
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# - Monitors washing machine load current, voltage, and power
|
||||
# - Monitors washing machine load current, voltage, power, and cumulative energy
|
||||
# - Load Energy integrates measured power over time and reports kWh
|
||||
# - Load Energy resets to zero if the ESPHome device reboots
|
||||
# - Home Assistant handles the reset because the sensor uses total_increasing
|
||||
# - Load Maximum Power 7 Days records the highest measured power
|
||||
# - Maximum power resets after 168 powered hours
|
||||
# - The maximum power value and elapsed-hour counter are retained across reboots
|
||||
# - The maximum power value is checked for saving every five minutes
|
||||
# - The elapsed-hour counter is checked for saving every six hours
|
||||
# - Reduced save frequency limits unnecessary ESP8266 flash writes
|
||||
# - An unexpected power loss may extend the reset period by up to approximately six hours
|
||||
# - No accurate clock or SNTP connection is required for the seven-day reset
|
||||
# - Provides a virtual relay switch that controls the physical relay and LED together
|
||||
# - Local button toggles the virtual relay switch
|
||||
# - On boot, the virtual relay is turned ON
|
||||
@@ -31,15 +45,18 @@
|
||||
# a) Home Assistant offline (network and MQTT online):
|
||||
# - Device continues running normally
|
||||
# - Local button still works
|
||||
# - MQTT remains available if your common MQTT package is enabled and broker is reachable
|
||||
# - Power, energy, running state, and maximum power continue operating locally
|
||||
# - MQTT remains available if the common MQTT package is enabled and broker is reachable
|
||||
#
|
||||
# b) MQTT offline (or HA/MQTT offline):
|
||||
# - Device continues running locally
|
||||
# - Local button, relay control, LED control, and power monitoring still work
|
||||
# - Energy integration and maximum power monitoring continue locally
|
||||
#
|
||||
# c) Entire WiFi/Network offline:
|
||||
# - Device continues running locally
|
||||
# - Local button, relay control, LED control, and power monitoring still work
|
||||
# - Energy integration and maximum power monitoring continue locally
|
||||
# - Accurate time is not needed; SNTP is not required for operation
|
||||
#:########################################################################################:#
|
||||
|
||||
@@ -57,7 +74,7 @@ substitutions:
|
||||
|
||||
# Project Naming
|
||||
project_name: "Sonoff Technologies.POW R1"
|
||||
project_version: "v1.1"
|
||||
project_version: "v1.2"
|
||||
|
||||
# Entity Naming
|
||||
entity_prefix: "Load"
|
||||
@@ -121,9 +138,14 @@ esphome:
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "${description_comment}"
|
||||
area: "${device_area}"
|
||||
|
||||
# Limit parallel compiler processes to reduce host RAM usage.
|
||||
compile_process_limit: 1
|
||||
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
on_boot:
|
||||
priority: 200
|
||||
then:
|
||||
@@ -157,6 +179,28 @@ logger:
|
||||
# number: GPIO2
|
||||
# inverted: true
|
||||
|
||||
#:########################################################################################:#
|
||||
# GLOBALS:
|
||||
# Retained maximum power and elapsed-hour counter
|
||||
# https://esphome.io/components/globals.html
|
||||
#:########################################################################################:#
|
||||
globals:
|
||||
# Highest measured power during the current seven-day period.
|
||||
# The value is checked for changes every five minutes before being saved.
|
||||
- id: max_power_7d
|
||||
type: float
|
||||
restore_value: true
|
||||
initial_value: '0.0'
|
||||
update_interval: 5min
|
||||
|
||||
# Number of powered hours elapsed in the current seven-day period.
|
||||
# The value is checked for saving every six hours to reduce flash writes.
|
||||
- id: max_power_hours_elapsed
|
||||
type: uint16_t
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
update_interval: 6h
|
||||
|
||||
#:########################################################################################:#
|
||||
# BINARY SENSORS:
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
@@ -178,7 +222,7 @@ binary_sensor:
|
||||
lambda: |-
|
||||
if (isnan(id(power).state)) {
|
||||
return {};
|
||||
} else if (id(power).state > 4) {
|
||||
} else if (id(power).state > 4.0f) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -194,13 +238,44 @@ sensor:
|
||||
cf_pin: GPIO14
|
||||
cf1_pin: GPIO13
|
||||
update_interval: 2s
|
||||
|
||||
current:
|
||||
name: "${entity_prefix} Current"
|
||||
device_class: current
|
||||
state_class: measurement
|
||||
unit_of_measurement: "A"
|
||||
accuracy_decimals: 2
|
||||
|
||||
voltage:
|
||||
name: "${entity_prefix} Voltage"
|
||||
device_class: voltage
|
||||
state_class: measurement
|
||||
unit_of_measurement: "V"
|
||||
accuracy_decimals: 1
|
||||
|
||||
power:
|
||||
name: "${entity_prefix} Power"
|
||||
id: power
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
unit_of_measurement: "W"
|
||||
accuracy_decimals: 1
|
||||
|
||||
# Update the seven-day maximum whenever a new peak is measured.
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!isnan(x) && x > id(max_power_7d)) {
|
||||
id(max_power_7d) = x;
|
||||
id(max_power_7d_sensor).publish_state(x);
|
||||
|
||||
ESP_LOGI(
|
||||
"max_power",
|
||||
"New seven-day maximum power: %.1f W",
|
||||
x
|
||||
);
|
||||
}
|
||||
|
||||
# on_value_range:
|
||||
# - above: 4.0
|
||||
# then:
|
||||
@@ -209,6 +284,64 @@ sensor:
|
||||
# then:
|
||||
# - light.turn_off: led
|
||||
|
||||
# Integrates instantaneous watts over time.
|
||||
# Watts integrated over hours produces Wh, then multiply converts Wh to kWh.
|
||||
- platform: integration
|
||||
name: "${entity_prefix} Energy"
|
||||
id: energy
|
||||
sensor: power
|
||||
time_unit: h
|
||||
integration_method: trapezoid
|
||||
restore: false
|
||||
unit_of_measurement: "kWh"
|
||||
device_class: energy
|
||||
state_class: total_increasing
|
||||
accuracy_decimals: 3
|
||||
filters:
|
||||
- multiply: 0.001
|
||||
|
||||
# Highest power reading recorded during the current 168 powered-hour period.
|
||||
- platform: template
|
||||
name: "${entity_prefix} Maximum Power 7 Days"
|
||||
id: max_power_7d_sensor
|
||||
unit_of_measurement: "W"
|
||||
device_class: power
|
||||
state_class: measurement
|
||||
accuracy_decimals: 1
|
||||
update_interval: 60s
|
||||
lambda: |-
|
||||
return id(max_power_7d);
|
||||
|
||||
#:########################################################################################:#
|
||||
# INTERVAL:
|
||||
# Seven-day maximum power reset
|
||||
# https://esphome.io/components/interval.html
|
||||
#:########################################################################################:#
|
||||
interval:
|
||||
# Count one powered hour at a time.
|
||||
# 168 hours equals seven days.
|
||||
- interval: 1h
|
||||
then:
|
||||
- lambda: |-
|
||||
id(max_power_hours_elapsed) += 1;
|
||||
|
||||
ESP_LOGD(
|
||||
"max_power",
|
||||
"Seven-day maximum power period: %u of 168 powered hours elapsed",
|
||||
id(max_power_hours_elapsed)
|
||||
);
|
||||
|
||||
if (id(max_power_hours_elapsed) >= 168) {
|
||||
id(max_power_hours_elapsed) = 0;
|
||||
id(max_power_7d) = 0.0f;
|
||||
id(max_power_7d_sensor).publish_state(0.0f);
|
||||
|
||||
ESP_LOGI(
|
||||
"max_power",
|
||||
"Seven-day maximum power value has been reset"
|
||||
);
|
||||
}
|
||||
|
||||
#:########################################################################################:#
|
||||
# SWITCH:
|
||||
# https://esphome.io/components/switch/
|
||||
|
||||
Reference in New Issue
Block a user