Edit esp-officeusbhubpower.yaml

This commit is contained in:
ESPHome Device Builder
2026-07-26 19:40:54 +12:00
parent edda2027cb
commit 260bd11320
+22 -13
View File
@@ -6,6 +6,7 @@
# https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officeusbhubpower.yaml # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officeusbhubpower.yaml
#:########################################################################################:# #:########################################################################################:#
# VERSIONS: # VERSIONS:
# V1.4 2026-07-26 Added retained relay status and reconnect republishing
# V1.3 2026-07-25 Standardized MQTT payloads: "ON"/"OFF" → "On"/"Off" # V1.3 2026-07-25 Standardized MQTT payloads: "ON"/"OFF" → "On"/"Off"
# V1.2 2026-07-20 Simplified local MQTT command and status topics to the device root # V1.2 2026-07-20 Simplified local MQTT command and status topics to the device root
# V1.1 2026-02-25 Updated yaml to zorruno layout V1.1 # V1.1 2026-02-25 Updated yaml to zorruno layout V1.1
@@ -24,10 +25,10 @@
#:########################################################################################:# #:########################################################################################:#
# MQTT COMMANDS: # MQTT COMMANDS:
# Command (set relay): # Command (set relay):
# - ${mqtt_command_topic} -> ON, OFF # - ${mqtt_command_topic} -> On, Off
# #
# Status (published from template sensor): # Status (published from template sensor):
# - ${mqtt_status_topic} -> ON, OFF # - ${mqtt_status_topic} -> On, Off (retained)
#:########################################################################################:# #:########################################################################################:#
# OFFLINE NOTES: # OFFLINE NOTES:
# a) Home Assistant OFFLINE, but Network and MQTT ONLINE # a) Home Assistant OFFLINE, but Network and MQTT ONLINE
@@ -56,7 +57,7 @@ substitutions:
# Project Naming # Project Naming
project_name: "Sonoff Technologies.Sonoff Basic V1" project_name: "Sonoff Technologies.Sonoff Basic V1"
project_version: "v1.3" project_version: "v1.4"
# Passwords & Secrets (Unfortunately, you cannot use substitutions inside secret names) # Passwords & Secrets (Unfortunately, you cannot use substitutions inside secret names)
api_key: !secret esp-api_key api_key: !secret esp-api_key
@@ -169,6 +170,16 @@ switch:
id: relay1 id: relay1
restore_mode: RESTORE_DEFAULT_ON restore_mode: RESTORE_DEFAULT_ON
icon: "${relay_icon}" icon: "${relay_icon}"
on_turn_on:
- mqtt.publish:
topic: "${mqtt_status_topic}"
payload: "On"
retain: true
on_turn_off:
- mqtt.publish:
topic: "${mqtt_status_topic}"
payload: "Off"
retain: true
#:########################################################################################:# #:########################################################################################:#
# BINARY SENSORS: # BINARY SENSORS:
@@ -201,16 +212,6 @@ binary_sensor:
name: "${relay_1_name} Status" name: "${relay_1_name} Status"
lambda: |- lambda: |-
return id(relay1).state; return id(relay1).state;
on_press:
- mqtt.publish:
topic: "${mqtt_status_topic}"
payload: "On"
retain: false
on_release:
- mqtt.publish:
topic: "${mqtt_status_topic}"
payload: "Off"
retain: false
#:########################################################################################:# #:########################################################################################:#
# STATUS LED: # STATUS LED:
@@ -228,6 +229,14 @@ status_led:
# https://esphome.io/components/mqtt.html # https://esphome.io/components/mqtt.html
#:########################################################################################:# #:########################################################################################:#
mqtt: mqtt:
on_connect:
then:
- mqtt.publish:
topic: "${mqtt_status_topic}"
payload: !lambda |-
return id(relay1).state ? "On" : "Off";
retain: true
on_message: on_message:
- topic: "${mqtt_command_topic}" - topic: "${mqtt_command_topic}"
payload: "On" payload: "On"