From 260bd113204dd3c05f20b650a576a999cfe8788b Mon Sep 17 00:00:00 2001 From: ESPHome Device Builder Date: Sun, 26 Jul 2026 19:40:54 +1200 Subject: [PATCH] Edit esp-officeusbhubpower.yaml --- esphome/esp-officeusbhubpower.yaml | 35 +++++++++++++++++++----------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/esphome/esp-officeusbhubpower.yaml b/esphome/esp-officeusbhubpower.yaml index 731c507..d59fdd9 100644 --- a/esphome/esp-officeusbhubpower.yaml +++ b/esphome/esp-officeusbhubpower.yaml @@ -6,6 +6,7 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-officeusbhubpower.yaml #:########################################################################################:# # 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.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 @@ -24,10 +25,10 @@ #:########################################################################################:# # MQTT COMMANDS: # Command (set relay): -# - ${mqtt_command_topic} -> ON, OFF +# - ${mqtt_command_topic} -> On, Off # # Status (published from template sensor): -# - ${mqtt_status_topic} -> ON, OFF +# - ${mqtt_status_topic} -> On, Off (retained) #:########################################################################################:# # OFFLINE NOTES: # a) Home Assistant OFFLINE, but Network and MQTT ONLINE @@ -56,7 +57,7 @@ substitutions: # Project Naming 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) api_key: !secret esp-api_key @@ -169,6 +170,16 @@ switch: id: relay1 restore_mode: RESTORE_DEFAULT_ON 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: @@ -201,16 +212,6 @@ binary_sensor: name: "${relay_1_name} Status" lambda: |- 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: @@ -228,6 +229,14 @@ status_led: # https://esphome.io/components/mqtt.html #:########################################################################################:# mqtt: + on_connect: + then: + - mqtt.publish: + topic: "${mqtt_status_topic}" + payload: !lambda |- + return id(relay1).state ? "On" : "Off"; + retain: true + on_message: - topic: "${mqtt_command_topic}" payload: "On"