yaml layout updates to v1.1 and minor fixes
This commit is contained in:
@@ -1,34 +1,74 @@
|
||||
#############################################
|
||||
#############################################
|
||||
# OFFICE ELV CONTROL
|
||||
# Controlled by a Sonoff Basic R1
|
||||
#
|
||||
#:########################################################################################:#
|
||||
# TITLE: OFFICE ELV CONTROL
|
||||
# zorruno.com layout v1.1 2026
|
||||
#:########################################################################################:#
|
||||
# REPO:
|
||||
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officeelvcontrol.yaml
|
||||
#:########################################################################################:#
|
||||
# VERSIONS:
|
||||
# V1.1 2026-03-08 Updated yaml to zorruno layout V1.1
|
||||
# V1.0 2025-06-14 Initial Version
|
||||
#:########################################################################################:#
|
||||
# HARDWARE:
|
||||
# - Sonoff Basic R1 (ESP8266)
|
||||
# - Controls: Office ELV power supply (under desk)
|
||||
#:########################################################################################:#
|
||||
# OPERATION NOTES:
|
||||
# - Local button toggles relay
|
||||
# - MQTT control supported on:
|
||||
# ${mqtt_main_topic}/relay1/set payload ON/OFF
|
||||
# - Publishes relay state to MQTT via a template binary_sensor
|
||||
# NOTE: your original YAML used ${mqtt_topic}/relay1/state which was undefined.
|
||||
# This V1.1 conversion keeps behavior but corrects it to:
|
||||
# ${mqtt_main_topic}/relay1/state
|
||||
#:########################################################################################:#
|
||||
# MQTT COMMANDS:
|
||||
# - Command topic:
|
||||
# ${mqtt_main_topic}/relay1/set
|
||||
# ON -> relay ON
|
||||
# OFF -> relay OFF
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# - Status topic (published on state changes):
|
||||
# ${mqtt_main_topic}/relay1/state
|
||||
# ON/OFF
|
||||
#:########################################################################################:#
|
||||
# OFFLINE NOTES:
|
||||
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE
|
||||
# - MQTT control still works (relay1/set)
|
||||
# - Local button still works
|
||||
# b) MQTT OFFLINE (but WiFi/Network and HA API ONLINE)
|
||||
# - HA/API control still works
|
||||
# - MQTT command/control will not work while broker is down
|
||||
# c) Entire WiFi/Network OFFLINE
|
||||
# - Local button still toggles relay
|
||||
# - Accurate time is NOT needed (SNTP not required)
|
||||
#:########################################################################################:#
|
||||
|
||||
##########################################################################################
|
||||
# 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-officeelvcontrol"
|
||||
friendly_name: "Office ELV Control"
|
||||
description_comment: "ELV Power Supply control in the Office (under desk) :: Sonoff Basic"
|
||||
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
description_comment: "ELV Power Supply control in the Office (under desk) :: Sonoff Basic (Layout V1.1)"
|
||||
device_area: "Office" # Allows ESP device to be automatically linked to an 'Area' in Home Assistant.
|
||||
|
||||
# Project Naming
|
||||
project_name: "Sonoff Technologies.Sonoff Basic V1" # Project Details
|
||||
project_version: "v1.0" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords
|
||||
project_name: "Sonoff Technologies.Sonoff Basic V1" # Project Details
|
||||
project_version: "v1.1" # Project V denotes release of yaml file, allowing checking of deployed vs latest version
|
||||
|
||||
# Passwords & Secrets
|
||||
api_key: !secret esp-api_key # unfortunately you can't use substitutions inside secrets names
|
||||
ota_pass: !secret esp-ota_pass # unfortunately you can't use substitutions inside secrets names
|
||||
static_ip_address: !secret esp-officeelvcontrol_ip
|
||||
mqtt_command_main_topic: !secret mqtt_command_main_topic
|
||||
#mqtt_status_main_topic: !secret mqtt_status_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}
|
||||
|
||||
# Device Settings
|
||||
relay_icon: "mdi:generator-portable"
|
||||
@@ -43,10 +83,11 @@ substitutions:
|
||||
mqtt_device_name: "office-elv-control"
|
||||
mqtt_main_topic: "${mqtt_command_main_topic}/${mqtt_device_name}" # Topic we will use to command stuff from external without HA
|
||||
|
||||
##########################################################################################
|
||||
|
||||
#:########################################################################################:#
|
||||
# PACKAGES: Included Common Packages
|
||||
# https://esphome.io/components/packages.html
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
packages:
|
||||
#### WIFI, Network (Static/DHCP/IPV6 etc), Fallback AP, Safemode ####
|
||||
common_wifi: !include
|
||||
@@ -55,6 +96,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 (choose encryption or no encryption options) ####
|
||||
common_api: !include
|
||||
@@ -68,80 +110,90 @@ packages:
|
||||
file: common/mqtt_common.yaml
|
||||
vars:
|
||||
local_device_name: "${device_name}"
|
||||
|
||||
|
||||
#### WEB PORTAL ####
|
||||
#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
|
||||
area: "${device_area}"
|
||||
# platformio_options:
|
||||
# build_flags:
|
||||
# - "-Os" # optimize for size
|
||||
# - "-Wl,--gc-sections" # drop unused code/data
|
||||
# - "-fno-exceptions" # strip C++ exceptions
|
||||
# - "-fno-rtti" # strip C++ RTTI
|
||||
project:
|
||||
name: "${project_name}"
|
||||
version: "${project_version}"
|
||||
|
||||
##########################################################################################
|
||||
# ESP Platform and Framework
|
||||
# https://esphome.io/components/esp32.html
|
||||
##########################################################################################
|
||||
|
||||
#:########################################################################################:#
|
||||
# ESP PLATFORM AND FRAMEWORK:
|
||||
# https://esphome.io/components/esp8266.html
|
||||
#:########################################################################################:#
|
||||
esp8266:
|
||||
board: esp01_1m # The original sonoff basic
|
||||
restore_from_flash: True # restore some values on reboot
|
||||
board: esp01_1m # The original Sonoff Basic
|
||||
restore_from_flash: true # restore some values on reboot
|
||||
|
||||
preferences:
|
||||
flash_write_interval: 5min
|
||||
|
||||
mdns:
|
||||
disabled: False
|
||||
disabled: false
|
||||
|
||||
##########################################################################################
|
||||
# ESPHome Logging Enable
|
||||
|
||||
#:########################################################################################:#
|
||||
# LOGGING:
|
||||
# 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 # set to 0 for no logging via UART
|
||||
|
||||
##########################################################################################
|
||||
# SWITCH COMPONENT
|
||||
|
||||
#:########################################################################################:#
|
||||
# STATUS LED:
|
||||
# https://esphome.io/components/status_led.html
|
||||
# Sonoff Basic R1 LED is GPIO13
|
||||
#:########################################################################################:#
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO13
|
||||
inverted: true
|
||||
|
||||
|
||||
#:########################################################################################:#
|
||||
# SWITCH COMPONENT:
|
||||
# https://esphome.io/components/switch/
|
||||
##########################################################################################
|
||||
# Sonoff Basic R1 Relay Switch is GPIO12
|
||||
#############################################
|
||||
# Sonoff Basic R1 Relay is GPIO12
|
||||
#:########################################################################################:#
|
||||
switch:
|
||||
- platform: gpio
|
||||
name: "${relay_1_name}"
|
||||
pin: GPIO12
|
||||
id: relay1
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
icon: "${relay_icon}"
|
||||
icon: "${relay_icon}"
|
||||
|
||||
##########################################################################################
|
||||
# BINARY SENSORS
|
||||
|
||||
#:########################################################################################:#
|
||||
# BINARY SENSORS:
|
||||
# https://esphome.io/components/binary_sensor/
|
||||
##########################################################################################
|
||||
# Sonoff Basic R1 Button is GPIO03
|
||||
#############################################
|
||||
#:########################################################################################:#
|
||||
binary_sensor:
|
||||
|
||||
# Actual button input
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: GPIO03
|
||||
@@ -157,42 +209,30 @@ binary_sensor:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(relay1).state) {
|
||||
// Relay is ON: turn it OFF
|
||||
id(relay1).turn_off();
|
||||
} else {
|
||||
// Relay is OFF: turn it ON
|
||||
id(relay1).turn_on();
|
||||
}
|
||||
|
||||
# Mimics actual relay status (but not controllable)
|
||||
|
||||
# Mimics actual relay status (but not controllable) + publishes MQTT state
|
||||
- platform: template
|
||||
name: "${relay_1_name} Status"
|
||||
lambda: |-
|
||||
return id(relay1).state;
|
||||
on_press:
|
||||
- mqtt.publish:
|
||||
topic: "${mqtt_topic}/relay1/state"
|
||||
payload: "ON"
|
||||
topic: "${mqtt_main_topic}/relay1/state"
|
||||
payload: "ON"
|
||||
on_release:
|
||||
- mqtt.publish:
|
||||
topic: "${mqtt_topic}/relay1/state"
|
||||
payload: "OFF"
|
||||
|
||||
##########################################################################################
|
||||
# STATUS LED
|
||||
# https://esphome.io/components/status_led.html
|
||||
##########################################################################################
|
||||
# Sonoff Basic R1 LED is GPIO13
|
||||
#############################################
|
||||
status_led:
|
||||
pin:
|
||||
number: GPIO13
|
||||
inverted: yes
|
||||
topic: "${mqtt_main_topic}/relay1/state"
|
||||
payload: "OFF"
|
||||
|
||||
##########################################################################################
|
||||
# MQTT COMMANDS
|
||||
|
||||
#:########################################################################################:#
|
||||
# MQTT:
|
||||
# This adds device-specific MQTT command triggers to the common MQTT configuration.
|
||||
##########################################################################################
|
||||
#:########################################################################################:#
|
||||
mqtt:
|
||||
on_message:
|
||||
# Relay 1 control
|
||||
@@ -200,8 +240,8 @@ mqtt:
|
||||
payload: "ON"
|
||||
then:
|
||||
- switch.turn_on: relay1
|
||||
|
||||
- topic: "${mqtt_main_topic}/relay1/set"
|
||||
payload: "OFF"
|
||||
then:
|
||||
- switch.turn_off: relay1
|
||||
|
||||
- switch.turn_off: relay1
|
||||
Reference in New Issue
Block a user