Edit esp-laundrydrypow.yaml
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-laundrydrypow.yaml
|
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-laundrydrypow.yaml
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# VERSIONS:
|
# 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.1 2026-03-11 Updated yaml to zorruno layout V1.1
|
||||||
# V1.0 2025-05-28 Initial Version
|
# V1.0 2025-05-28 Initial Version
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
@@ -20,7 +23,16 @@
|
|||||||
# - Reference: https://devices.esphome.io/devices/Sonoff-POW-R1
|
# - Reference: https://devices.esphome.io/devices/Sonoff-POW-R1
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# OPERATION NOTES:
|
# OPERATION NOTES:
|
||||||
# - Monitors dryer load current, voltage, and power
|
# - Monitors dryer 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 elapsed-hour counter is saved every six hours to reduce 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
|
# - Provides a virtual relay switch that controls the physical relay and LED together
|
||||||
# - Local button toggles the virtual relay switch
|
# - Local button toggles the virtual relay switch
|
||||||
# - On boot, the virtual relay is turned ON
|
# - On boot, the virtual relay is turned ON
|
||||||
@@ -31,15 +43,18 @@
|
|||||||
# a) Home Assistant offline (network and MQTT online):
|
# a) Home Assistant offline (network and MQTT online):
|
||||||
# - Device continues running normally
|
# - Device continues running normally
|
||||||
# - Local button still works
|
# - 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):
|
# b) MQTT offline (or HA/MQTT offline):
|
||||||
# - Device continues running locally
|
# - Device continues running locally
|
||||||
# - Local button, relay control, LED control, and power monitoring still work
|
# - Local button, relay control, LED control, and power monitoring still work
|
||||||
|
# - Energy integration and maximum power monitoring continue locally
|
||||||
#
|
#
|
||||||
# c) Entire WiFi/Network offline:
|
# c) Entire WiFi/Network offline:
|
||||||
# - Device continues running locally
|
# - Device continues running locally
|
||||||
# - Local button, relay control, LED control, and power monitoring still work
|
# - 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
|
# - Accurate time is not needed; SNTP is not required for operation
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
|
|
||||||
@@ -57,7 +72,7 @@ substitutions:
|
|||||||
|
|
||||||
# Project Naming
|
# Project Naming
|
||||||
project_name: "Sonoff Technologies.POW R1"
|
project_name: "Sonoff Technologies.POW R1"
|
||||||
project_version: "v1.1"
|
project_version: "v1.2"
|
||||||
|
|
||||||
# Entity Naming
|
# Entity Naming
|
||||||
entity_prefix: "Load"
|
entity_prefix: "Load"
|
||||||
@@ -124,6 +139,7 @@ esphome:
|
|||||||
project:
|
project:
|
||||||
name: "${project_name}"
|
name: "${project_name}"
|
||||||
version: "${project_version}"
|
version: "${project_version}"
|
||||||
|
|
||||||
on_boot:
|
on_boot:
|
||||||
priority: 200
|
priority: 200
|
||||||
then:
|
then:
|
||||||
@@ -157,6 +173,28 @@ logger:
|
|||||||
# number: GPIO2
|
# number: GPIO2
|
||||||
# inverted: true
|
# 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.
|
||||||
|
# Saved every six hours to reduce ESP8266 flash writes.
|
||||||
|
- id: max_power_hours_elapsed
|
||||||
|
type: uint16_t
|
||||||
|
restore_value: true
|
||||||
|
initial_value: '0'
|
||||||
|
update_interval: 6h
|
||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# BINARY SENSORS:
|
# BINARY SENSORS:
|
||||||
# https://esphome.io/components/binary_sensor/
|
# https://esphome.io/components/binary_sensor/
|
||||||
@@ -178,7 +216,7 @@ binary_sensor:
|
|||||||
lambda: |-
|
lambda: |-
|
||||||
if (isnan(id(power).state)) {
|
if (isnan(id(power).state)) {
|
||||||
return {};
|
return {};
|
||||||
} else if (id(power).state > 4) {
|
} else if (id(power).state > 4.0f) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -194,13 +232,44 @@ sensor:
|
|||||||
cf_pin: GPIO14
|
cf_pin: GPIO14
|
||||||
cf1_pin: GPIO13
|
cf1_pin: GPIO13
|
||||||
update_interval: 2s
|
update_interval: 2s
|
||||||
|
|
||||||
current:
|
current:
|
||||||
name: "${entity_prefix} Current"
|
name: "${entity_prefix} Current"
|
||||||
|
device_class: current
|
||||||
|
state_class: measurement
|
||||||
|
unit_of_measurement: "A"
|
||||||
|
accuracy_decimals: 2
|
||||||
|
|
||||||
voltage:
|
voltage:
|
||||||
name: "${entity_prefix} Voltage"
|
name: "${entity_prefix} Voltage"
|
||||||
|
device_class: voltage
|
||||||
|
state_class: measurement
|
||||||
|
unit_of_measurement: "V"
|
||||||
|
accuracy_decimals: 1
|
||||||
|
|
||||||
power:
|
power:
|
||||||
name: "${entity_prefix} Power"
|
name: "${entity_prefix} Power"
|
||||||
id: 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:
|
# on_value_range:
|
||||||
# - above: 4.0
|
# - above: 4.0
|
||||||
# then:
|
# then:
|
||||||
@@ -209,6 +278,64 @@ sensor:
|
|||||||
# then:
|
# then:
|
||||||
# - light.turn_off: led
|
# - 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:
|
# SWITCH:
|
||||||
# https://esphome.io/components/switch/
|
# https://esphome.io/components/switch/
|
||||||
|
|||||||
Reference in New Issue
Block a user