diff --git a/esphome/esp-occupancyoffice.yaml b/esphome/esp-occupancyoffice.yaml index 686c95f..358d03f 100644 --- a/esphome/esp-occupancyoffice.yaml +++ b/esphome/esp-occupancyoffice.yaml @@ -6,9 +6,10 @@ # https://home.fox.co.nz/gitea/zorruno/zorruno-homeassistant/src/branch/master/esphome/esp-occupancyoffice.yaml #:########################################################################################:# # VERSIONS: -# v1.2 2026-07-25 Removed MQTT light control commands. Light 2-way sync is now handled -# directly between esp-officelights and esp-officeduallights via MQTT. -# This device now only reports occupancy and environment data to HA. +# v1.3 2026-07-25 Restored MQTT light timer commands. Light 2-way sync is handled directly +# between esp-officelights and esp-officeduallights via MQTT. This device +# sends On/timer commands to all 4 light topics for occupancy-based control. +# v1.2 2026-07-25 Removed MQTT light control commands (reverted) # v1.1 2026-04-24 Added MQTT remote timer command script triggered by mmWave occupancy or movement # v1.0 2026-02-25 Updated yaml to zorruno layout V1.1 #:########################################################################################:# @@ -36,18 +37,23 @@ # - Publishes a text occupancy state (Movement/Occupancy/Clearance) and binary sensors for: # - mmWave Occupancy or Movement (occupancy) # - mmWave Movement (motion) +# - When mmWave Occupancy or Movement turns ON, this device publishes MQTT On commands to +# all 4 office light topics. When it turns OFF, it publishes timer commands (10s or 360s) +# so lights stay on briefly after the room is vacated. +# - Light 2-way sync between esp-officelights and esp-officeduallights ensures both switches +# stay in sync regardless of which device initiates the change. # - BLE scanning is started/stopped based on HA API client connection (reduces BLE load when unused). -# - Light control is handled by direct MQTT 2-way sync between esp-officelights and -# esp-officeduallights. This device does not control lights. #:########################################################################################:# # OFFLINE NOTES: # a) Home Assistant OFFLINE, but Network and MQTT ONLINE # - Device continues running mmWave logic and environment sensors. +# - MQTT light timer commands still function if MQTT is online. # - HA entities will update again when HA returns. -# - Light control is not affected (handled by esp-officelights/officeduallights directly). +# - Physical buttons on esp-officelights and esp-officeduallights still work and cancel +# any active timer if pressed. # b) MQTT OFFLINE (or broker unreachable) # - Device continues running locally and via HA API (if HA is reachable). -# - HA entities will update again when MQTT returns. +# - MQTT-based light timer commands will not function until MQTT returns. # c) Entire WiFi/Network OFFLINE # - Device continues running local mmWave/environment logic, but HA/MQTT integration is unavailable. # - Accurate time is NOT needed (SNTP not needed): logic uses relative time (time since boot), @@ -67,7 +73,7 @@ substitutions: # Project Naming project_name: "HiLink.LD1125H Office Occupancy" - project_version: "v1.2" + project_version: "v1.3" # Passwords & Secrets (unfortunately you can't use substitutions inside secrets names) api_key: !secret esp-occupancyoffice_api_key @@ -84,6 +90,31 @@ substitutions: log_level: "INFO" # NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE update_interval: "60s" # general sensor update interval + # Remote light timer payloads, in seconds. + remote_timer_left_lights_payload: "10" + remote_timer_right_lights_payload: "360" + + # MQTT REMOTE Controls + mqtt_remote_device1_name: "office-dual-lights-left" + mqtt_remote_device1_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device1_name}" + mqtt_remote_device1_command1: "On" + mqtt_remote_device1_command2: "${remote_timer_left_lights_payload}" + + mqtt_remote_device2_name: "office-dual-lights-right" + mqtt_remote_device2_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device2_name}" + mqtt_remote_device2_command1: "On" + mqtt_remote_device2_command2: "${remote_timer_right_lights_payload}" + + mqtt_remote_device3_name: "office-main-lights-left" + mqtt_remote_device3_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device3_name}" + mqtt_remote_device3_command1: "On" + mqtt_remote_device3_command2: "${remote_timer_left_lights_payload}" + + mqtt_remote_device4_name: "office-main-lights-right" + mqtt_remote_device4_command_topic: "${mqtt_command_main_topic}/${mqtt_remote_device4_name}" + mqtt_remote_device4_command1: "On" + mqtt_remote_device4_command2: "${remote_timer_right_lights_payload}" + #:########################################################################################:# # PACKAGES: Included Common Packages # https://esphome.io/components/packages.html @@ -474,6 +505,59 @@ text_sensor: id: ld1125h_occupancy icon: "mdi:motion-sensor" +#:########################################################################################:# +# SCRIPT +# https://esphome.io/components/script.html +#:########################################################################################:# +script: + - id: send_remote_light_on_commands + mode: restart + then: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device1_command1}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device2_command_topic}" + payload: "${mqtt_remote_device2_command1}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device3_command_topic}" + payload: "${mqtt_remote_device3_command1}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device4_command_topic}" + payload: "${mqtt_remote_device4_command1}" + qos: 0 + retain: false + + - id: send_remote_light_timer_commands + mode: restart + then: + - mqtt.publish: + topic: "${mqtt_remote_device1_command_topic}" + payload: "${mqtt_remote_device1_command2}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device2_command_topic}" + payload: "${mqtt_remote_device2_command2}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device3_command_topic}" + payload: "${mqtt_remote_device3_command2}" + qos: 0 + retain: false + - mqtt.publish: + topic: "${mqtt_remote_device4_command_topic}" + payload: "${mqtt_remote_device4_command2}" + qos: 0 + retain: false + #:########################################################################################:# # BINARY SENSOR # https://esphome.io/components/binary_sensor/ @@ -483,6 +567,10 @@ binary_sensor: name: "mmWave Occupancy or Movement" id: ld1125h_movocc_binary device_class: occupancy + on_press: + - script.execute: send_remote_light_on_commands + on_release: + - script.execute: send_remote_light_timer_commands - platform: template name: "mmWave Movement"