more esphome devices and fixes

This commit is contained in:
root
2026-04-03 21:34:23 +13:00
parent e09931360a
commit f7bfa78835
96 changed files with 4870 additions and 2523 deletions
+147 -86
View File
@@ -1,39 +1,82 @@
#############################################
#############################################
# LAUNDRY BENCH PLUGS POWER AND SWITCH
#:########################################################################################:#
# TITLE: LAUNDRY BENCH PLUGS POWER AND SWITCH
# zorruno.com layout v1.1 2026
#:########################################################################################:#
# REPO:
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-laundryplugpow.yaml
#:########################################################################################:#
# VERSIONS:
# V1.1 2026-03-11 Updated yaml to zorruno layout V1.1
# V1.0 2025-03-28 Initial Version
#############################################
# Sonoff POW R1
# https://devices.esphome.io/devices/Sonoff-POW-R1
#:########################################################################################:#
# HARDWARE:
# - Sonoff POW R1
# - ESP8266 based
# - HLW8012 power monitoring
# - Single relay output
# - Blue status LED on GPIO15
# - Local push button on GPIO0
# - Relay output on GPIO12
# - Reference: https://devices.esphome.io/devices/Sonoff-POW-R1
#:########################################################################################:#
# OPERATION NOTES:
# - Monitors plug load current, voltage, and power
# - 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
# - "Load Running" turns ON when measured power is above 4 W
# - "Load Running" uses delayed_off: 15s to avoid rapid state changes
#:########################################################################################:#
# OFFLINE NOTES:
# 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
#
# NOTES
# -
# b) MQTT offline (or HA/MQTT offline):
# - Device continues running locally
# - Local button, relay control, LED control, and power monitoring still work
#
#############################################
#############################################
# c) Entire WiFi/Network offline:
# - Device continues running locally
# - Local button, relay control, LED control, and power monitoring still work
# - Accurate time is not needed; SNTP is not required for operation
#:########################################################################################:#
#############################################
# SPECIFIC DEVICE VARIABLE SUBSTITUTIONS
#:########################################################################################:#
# SUBSTITUTIONS:
# Specific device variable substitutions
# If NOT using a secrets file, just replace these with the passwords etc (in quotes)
#############################################
#:########################################################################################:#
substitutions:
device_name: "esp-laundryplugpow" # Reference name for the device in the system.
project_name: "Sonoff Technologies.POW R1" # Project Details
project_version: "v1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
entity_prefix: "Load" # Simple device name where we want to prefix a sensor or switch, eg "Load" Current.
# Device Naming
device_name: "esp-laundryplugpow"
friendly_name: "Laundry Bench Plug Power"
description_comment: "Laundry Bench Plug Power and switch override using a Sonoff Pow R1."
device_area: "Laundry" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
api_key: !secret esp-laundryplugpow_api_key # unfortunately you can't use substitutions inside secrets names
ota_pass: !secret esp-laundryplugpow_ota_pass # unfortunately you can't use substitutions inside secrets names
static_ip_address: !secret esp-laundryplugpow_ip
log_level: "INFO" # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
update_interval: "60s" # update time for for general sensors etc
description_comment: "Laundry Bench Plug Power and switch override using a Sonoff Pow R1. (Layout V1.1)"
device_area: "Laundry"
##########################################################################################
# PACKAGES: Included Common Packages
# Project Naming
project_name: "Sonoff Technologies.POW R1"
project_version: "v1.1"
# Entity Naming
entity_prefix: "Load"
# Passwords and Secrets
api_key: !secret esp-laundryplugpow_api_key
ota_pass: !secret esp-laundryplugpow_ota_pass
static_ip_address: !secret esp-laundryplugpow_ip
current_ip_address: ${static_ip_address}
# Device Settings
log_level: "INFO"
update_interval: "60s"
#:########################################################################################:#
# PACKAGES:
# Included common packages
# https://esphome.io/components/packages.html
##########################################################################################
#:########################################################################################:#
packages:
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
common_wifi: !include
@@ -41,12 +84,13 @@ packages:
vars:
local_device_name: "${device_name}"
local_static_ip_address: "${static_ip_address}"
local_current_ip_address: "${current_ip_address}"
local_ota_pass: "${ota_pass}"
#### HOME ASSISTANT API (choose encryption or no encryption options) ####
common_api: !include
file: common/api_common.yaml
#file: common/api_common_noencryption.yaml
# file: common/api_common_noencryption.yaml
vars:
local_api_key: "${api_key}"
@@ -55,137 +99,154 @@ packages:
file: common/mqtt_common.yaml
vars:
local_device_name: "${device_name}"
#### WEB PORTAL ####
#common_webportal: !include common/webportal_common.yaml
# common_webportal: !include common/webportal_common.yaml
#### SNTP (Only use if you want/need accurate timeclocks) ####
#common_sntp: !include common/sntp_common.yaml
# common_sntp: !include common/sntp_common.yaml
#### DIAGNOSTICS Sensors ####
diag_basic: !include common/include_basic_diag_sensors.yaml
diag_more: !include common/include_more_diag_sensors.yaml
#diag_debug: !include common/include_debug_diag_sensors.yaml
#diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
diag_basic: !include common/include_basic_diag_sensors.yaml
diag_more: !include common/include_more_diag_sensors.yaml
# diag_debug: !include common/include_debug_diag_sensors.yaml
# diag_resetcount: !include common/include_resetcount_diag_sensors.yaml
#############################################
# ESPHome
#:########################################################################################:#
# ESPHOME:
# https://esphome.io/components/esphome.html
#############################################
#:########################################################################################:#
esphome:
name: "${device_name}"
friendly_name: "${friendly_name}"
comment: "${description_comment}" # Appears on the esphome page in HA
comment: "${description_comment}"
area: "${device_area}"
project:
name: "${project_name}"
version: "${project_version}"
on_boot:
on_boot:
priority: 200
then:
- switch.turn_on: "virtual_button"
- switch.turn_on: virtual_button
#############################################
# ESP Platform and Framework
# https://esphome.io/components/esp32.html
#############################################
#:########################################################################################:#
# ESP PLATFORM AND FRAMEWORK:
# https://esphome.io/components/esp8266.html
#:########################################################################################:#
esp8266:
board: esp01_1m
early_pin_init: False # Initialise pins early to known values. Recommended false where switches are involved. Defaults to True.
board_flash_mode: dout # Default is dout
early_pin_init: false
board_flash_mode: dout
#############################################
# ESPHome Logging Enable
#:########################################################################################:#
# LOGGER:
# https://esphome.io/components/logger.html
#############################################
#:########################################################################################:#
logger:
level: ${log_level} #INFO Level suggested, or DEBUG for testing
#baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM)
#esp8266_store_log_strings_in_flash: false
#tx_buffer_size: 64
level: "${log_level}"
# baud_rate: 0
# esp8266_store_log_strings_in_flash: false
# tx_buffer_size: 64
#############################################
# STATUS LED
#:########################################################################################:#
# STATUS LED:
# https://esphome.io/components/status_led.html
#############################################
#status_led:
# pin:
# number: GPIO2
# inverted: yes
#:########################################################################################:#
# status_led:
# pin:
# number: GPIO2
# inverted: true
#############################################
# SENSORS
#:########################################################################################:#
# BINARY SENSORS:
# https://esphome.io/components/binary_sensor/
#############################################
#:########################################################################################:#
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: Button
inverted: true
name: "Button"
on_press:
- switch.toggle: virtual_button
- platform: template
name: ${entity_prefix} Running
name: "${entity_prefix} Running"
filters:
- delayed_off: 15s
lambda: |-
if (isnan(id(power).state)) {
return {};
} else if (id(power).state > 4) {
// Running
return true;
} else {
// Not running
return false;
}
#:########################################################################################:#
# SENSORS:
# https://esphome.io/components/sensor/
#:########################################################################################:#
sensor:
- platform: hlw8012
sel_pin: 5
cf_pin: 14
cf1_pin: 13
sel_pin: GPIO5
cf_pin: GPIO14
cf1_pin: GPIO13
update_interval: 2s
current:
name: ${entity_prefix} Current
name: "${entity_prefix} Current"
voltage:
name: ${entity_prefix} Voltage
name: "${entity_prefix} Voltage"
power:
name: ${entity_prefix} Power
name: "${entity_prefix} Power"
id: power
#on_value_range:
# - above: 4.0
# then:
# - light.turn_on: led
# - below: 3.0
# then:
# - light.turn_off: led
# on_value_range:
# - above: 4.0
# then:
# - light.turn_on: led
# - below: 3.0
# then:
# - light.turn_off: led
#:########################################################################################:#
# SWITCH:
# https://esphome.io/components/switch/
#:########################################################################################:#
switch:
- platform: template
name: "Relay"
optimistic: true
id: virtual_button
optimistic: true
turn_on_action:
- switch.turn_on: relay
- light.turn_on: led
turn_off_action:
- switch.turn_off: relay
- light.turn_off: led
- platform: gpio
id: relay
pin: GPIO12
#restore_mode: ALWAYS_ON # Or RESTORE_DEFAULT_ON/RESTORE_DEFAULT_OFF
# restore_mode: ALWAYS_ON
#:########################################################################################:#
# OUTPUT:
# https://esphome.io/components/output/
#:########################################################################################:#
output:
- platform: esp8266_pwm
id: pow_blue_led
pin:
number: GPIO15
inverted: True
inverted: true
#:########################################################################################:#
# LIGHT:
# https://esphome.io/components/light/
#:########################################################################################:#
light:
- platform: monochromatic
name: Status LED
name: "Status LED"
output: pow_blue_led
id: led