yaml layout updates to v1.x
This commit is contained in:
@@ -1,43 +1,69 @@
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# DATA CUPBOARD FAN CONTROL
|
||||
# Fan control for Data Cupboard
|
||||
#
|
||||
# Hardware: Yunshan 7-30V 10A Relay Board (HW-622) with ESP8266MOD
|
||||
#
|
||||
#:########################################################################################:#
|
||||
# TITLE: DATA CUPBOARD FAN CONTROL
|
||||
# zorruno.com layout v1.1 2026
|
||||
#:########################################################################################:#
|
||||
# REPO:
|
||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-datacupboardfans.yaml
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.3 2026-02-20 Remove invalid allow_other_uses on pulse_counter pins (ESPHome 2026.2.x)
|
||||
# V1.2 2026-02-20 Use common SNTP package, and publish fan fault/status via interval script
|
||||
# V1.1 2026-02-20 Fix template binary_sensor update method for ESPHome 2026.2.x
|
||||
# V1.0 2026-02-20 Initial Version
|
||||
#
|
||||
# NOTES
|
||||
#:########################################################################################:#
|
||||
# HARDWARE:
|
||||
# Yunshan 7-30V 10A Relay Board (HW-622) with ESP8266MOD
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# - Fan tach inputs are on GPIO1/GPIO3 (UART pins). Logger UART is disabled (baud_rate: 0).
|
||||
# - DHT22 data is on GPIO0 (boot-strap pin). Usually OK, but if you ever get boot issues,
|
||||
# move the DHT22 to a different GPIO if your board allows.
|
||||
# - Using common/sntp_common.yaml for time and diagnostic time text sensors.
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# - Thermostat logic uses hysteresis thresholds (On temp / Off temp) plus a manual override.
|
||||
# - Fan fault is evaluated periodically, with grace windows after boot and relay changes.
|
||||
#:########################################################################################:#
|
||||
# MQTT COMMANDS:
|
||||
# Base topic: ${mqtt_main_topic}
|
||||
# - ${mqtt_main_topic}/relay/set : ON,OFF
|
||||
# - ${mqtt_main_topic}/override/set : ON,OFF
|
||||
#:########################################################################################:#
|
||||
# OFFLINE NOTES:
|
||||
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
|
||||
# - Fan control logic still runs on-device (thermostat + override)
|
||||
# - MQTT commands still work and fan status/fault still publishes via MQTT (common_mqtt)
|
||||
# b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE)
|
||||
# - Fan control logic still runs on-device (thermostat + override)
|
||||
# - HA can still control entities via API, but MQTT command topics will not work
|
||||
# c) Entire WiFi/Network OFFLINE
|
||||
# - Fan control logic still runs on-device (thermostat + override)
|
||||
# - Timeclocks will drift without network (SNTP). Time of day can be reset by powering off then on again at 12pm (midday)
|
||||
#:########################################################################################:#
|
||||
|
||||
##########################################################################################
|
||||
# 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 Naming
|
||||
device_name: "esp-datacupboardfans"
|
||||
friendly_name: "Data Cupboard Fans"
|
||||
description_comment: "Fan control for Data Cupboard"
|
||||
description_comment: "Fan control for Data Cupboard (Layout V1.1)"
|
||||
device_area: "Data Cupboard"
|
||||
|
||||
# Project Naming
|
||||
project_name: "Yunshan.HW-622 ESP8266MOD Relay Board"
|
||||
project_version: "v1.3"
|
||||
|
||||
# Passwords
|
||||
# Passwords and Secrets (Unfortunately, you cannot use substitutions inside secret names)
|
||||
api_key: !secret esp-api_key
|
||||
ota_pass: !secret esp-ota_pass
|
||||
static_ip_address: !secret esp-datacupboardfans_ip
|
||||
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||
|
||||
# If we are changing IP addresses, you must update the current IP address here, otherwise it remains
|
||||
# Don't forget to switch it back when changed.
|
||||
current_ip_address: ${static_ip_address}
|
||||
|
||||
# MQTT Controls
|
||||
mqtt_device_name: "data-cupboard-fans"
|
||||
mqtt_main_topic: "${mqtt_command_main_topic}/${mqtt_device_name}"
|
||||
@@ -67,9 +93,10 @@ substitutions:
|
||||
default_temp_on: "35"
|
||||
default_temp_off: "28"
|
||||
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# PACKAGES: Included Common Packages
|
||||
##########################################################################################
|
||||
# https://esphome.io/components/packages.html
|
||||
#:########################################################################################:#
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
@@ -78,6 +105,7 @@ packages:
|
||||
local_device_name: "${device_name}"
|
||||
local_static_ip_address: "${static_ip_address}"
|
||||
local_ota_pass: "${ota_pass}"
|
||||
local_current_ip_address: "${current_ip_address}"
|
||||
|
||||
#### HOME ASSISTANT API ####
|
||||
common_api: !include
|
||||
@@ -99,9 +127,10 @@ packages:
|
||||
diag_basic: !include common/include_basic_diag_sensors.yaml
|
||||
diag_more: !include common/include_more_diag_sensors.yaml
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# ESPHOME:
|
||||
# https://esphome.io/components/esphome.html
|
||||
#:########################################################################################:#
|
||||
esphome:
|
||||
name: "${device_name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
@@ -120,9 +149,11 @@ esphome:
|
||||
- script.execute: apply_fan_control
|
||||
- script.execute: evaluate_fan_fault
|
||||
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# ESP PLATFORM AND FRAMEWORK:
|
||||
# https://esphome.io/components/esp8266/
|
||||
# https://esphome.io/components/esp32/
|
||||
#:########################################################################################:#
|
||||
esp8266:
|
||||
board: esp12e
|
||||
restore_from_flash: true
|
||||
@@ -133,75 +164,87 @@ preferences:
|
||||
mdns:
|
||||
disabled: false
|
||||
|
||||
##########################################################################################
|
||||
# LOGGING
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# LOGGING:
|
||||
# https://esphome.io/components/logger.html
|
||||
#:########################################################################################:#
|
||||
logger:
|
||||
level: "${log_level}"
|
||||
baud_rate: 0
|
||||
|
||||
##########################################################################################
|
||||
# GLOBALS
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# GLOBAL VARIABLES:
|
||||
# https://esphome.io/components/globals.html
|
||||
#:########################################################################################:#
|
||||
globals:
|
||||
# Max temperature tracking
|
||||
- id: g_max_temp_today
|
||||
type: float
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "-1000.0"
|
||||
|
||||
- id: g_max_temp_yesterday
|
||||
type: float
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "-1000.0"
|
||||
|
||||
- id: g_max_temp_month
|
||||
type: float
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "-1000.0"
|
||||
|
||||
- id: g_max_temp_last_month
|
||||
type: float
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "-1000.0"
|
||||
|
||||
- id: g_max_temp_year
|
||||
type: float
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "-1000.0"
|
||||
|
||||
# Last seen date parts (for rollover)
|
||||
- id: g_last_day
|
||||
type: int
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "0"
|
||||
|
||||
- id: g_last_month
|
||||
type: int
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "0"
|
||||
|
||||
- id: g_last_year
|
||||
type: int
|
||||
restore_value: yes
|
||||
restore_value: true
|
||||
initial_value: "0"
|
||||
|
||||
# Fault evaluation grace timing
|
||||
- id: boot_ms
|
||||
type: uint32_t
|
||||
restore_value: no
|
||||
initial_value: "0"
|
||||
- id: relay_last_change_ms
|
||||
type: uint32_t
|
||||
restore_value: no
|
||||
restore_value: false
|
||||
initial_value: "0"
|
||||
|
||||
##########################################################################################
|
||||
# INTERVAL (periodic evaluations)
|
||||
- id: relay_last_change_ms
|
||||
type: uint32_t
|
||||
restore_value: false
|
||||
initial_value: "0"
|
||||
|
||||
#:########################################################################################:#
|
||||
# INTERVAL:
|
||||
# https://esphome.io/components/interval.html
|
||||
#:########################################################################################:#
|
||||
# Periodic evaluations
|
||||
# NOTE: common_sntp also defines its own interval (60s) for its fallback clock.
|
||||
##########################################################################################
|
||||
interval:
|
||||
- interval: 5s
|
||||
then:
|
||||
- script.execute: evaluate_fan_fault
|
||||
|
||||
##########################################################################################
|
||||
# SWITCHES (Relay + Override)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# SWITCHES:
|
||||
# https://esphome.io/components/switch/
|
||||
#:########################################################################################:#
|
||||
switch:
|
||||
# Relay output (GPIO4) - powers both fans
|
||||
- platform: gpio
|
||||
@@ -239,9 +282,11 @@ switch:
|
||||
- script.execute: apply_fan_control
|
||||
- script.execute: evaluate_fan_fault
|
||||
|
||||
##########################################################################################
|
||||
# NUMBERS (On/Off thresholds with hysteresis)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# NUMBERS:
|
||||
# https://esphome.io/components/number/
|
||||
#:########################################################################################:#
|
||||
# On/Off thresholds with hysteresis
|
||||
number:
|
||||
- platform: template
|
||||
name: "Fans On Temperature"
|
||||
@@ -275,9 +320,10 @@ number:
|
||||
set_action:
|
||||
- script.execute: apply_fan_control
|
||||
|
||||
##########################################################################################
|
||||
# BINARY SENSORS (Door + Fault)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# BINARY SENSORS:
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
#:########################################################################################:#
|
||||
binary_sensor:
|
||||
# Door status on GPIO5
|
||||
- platform: gpio
|
||||
@@ -298,17 +344,19 @@ binary_sensor:
|
||||
id: fan_fault
|
||||
device_class: problem
|
||||
|
||||
##########################################################################################
|
||||
# STATUS LED (GPIO2)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# STATUS LED:
|
||||
# https://esphome.io/components/status_led.html
|
||||
#:########################################################################################:#
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO2
|
||||
inverted: true
|
||||
|
||||
##########################################################################################
|
||||
# SENSORS (Temp/Humidity + Fan RPM + Max temp templates)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# SENSORS:
|
||||
# https://esphome.io/components/sensor/
|
||||
#:########################################################################################:#
|
||||
sensor:
|
||||
# DHT22 on GPIO0
|
||||
- platform: dht
|
||||
@@ -419,19 +467,22 @@ sensor:
|
||||
lambda: |-
|
||||
return id(g_max_temp_year);
|
||||
|
||||
##########################################################################################
|
||||
# TEXT SENSOR (Normal/Fault status) - published by script
|
||||
#:########################################################################################:#
|
||||
# TEXT SENSORS:
|
||||
# https://esphome.io/components/text_sensor/
|
||||
#:########################################################################################:#
|
||||
# Normal/Fault status - published by script
|
||||
# NOTE: common_sntp also defines its own text_sensors (time status etc).
|
||||
##########################################################################################
|
||||
text_sensor:
|
||||
- platform: template
|
||||
name: "${fan_status_name}"
|
||||
id: fan_status
|
||||
icon: "mdi:fan-alert"
|
||||
|
||||
##########################################################################################
|
||||
# SCRIPTS
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# SCRIPTS:
|
||||
# https://esphome.io/components/script.html
|
||||
#:########################################################################################:#
|
||||
script:
|
||||
# Apply fan control logic (override + hysteresis thresholds)
|
||||
- id: apply_fan_control
|
||||
@@ -498,9 +549,6 @@ script:
|
||||
|
||||
const float req = id(fan_relay).state ? ${rpm_min_when_relay_on} : ${rpm_min_when_relay_off};
|
||||
|
||||
// Requirement as requested:
|
||||
// - Relay OFF => both fans must be > 1800 RPM
|
||||
// - Relay ON => both fans must be > 3000 RPM
|
||||
const bool fault = (r1 < req) || (r2 < req);
|
||||
|
||||
id(fan_fault).publish_state(fault);
|
||||
@@ -569,9 +617,9 @@ script:
|
||||
id(max_temp_last_month).publish_state(id(g_max_temp_last_month));
|
||||
id(max_temp_year).publish_state(id(g_max_temp_year));
|
||||
|
||||
##########################################################################################
|
||||
# MQTT COMMANDS (device-specific)
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
# MQTT (DEVICE-SPECIFIC COMMAND SUBSCRIPTIONS):
|
||||
#:########################################################################################:#
|
||||
mqtt:
|
||||
on_message:
|
||||
# Relay control
|
||||
|
||||
Reference in New Issue
Block a user