various tidyups

This commit is contained in:
zorruno
2026-07-29 23:18:11 +12:00
parent adb533d6a3
commit dd13f52feb
22 changed files with 6837 additions and 4057 deletions
@@ -1,8 +1,12 @@
################################################################################
# PACKAGE: Office Lights And Power Backup Occupancy Automation
# PACKAGE: Office Power Backup Occupancy Automation
################################################################################
#
# Version:
# - 1.1 - 2026-07-25
# - Stripped light control (now handled by direct MQTT)
# - Retains power supply backup control only
#
# - 1.0 - 2026-04-25
# - Initial package version.
# - Backup automation for Office lights and Office power.
@@ -10,19 +14,18 @@
# - Uses Office spare button / relay as a backup manual master.
#
# Operation:
# - Turns Office lights and power on when the Office mmWave occupancy sensor
# - Turns Office power supplies on when the Office mmWave occupancy sensor
# detects occupancy or movement.
#
# - Turns Office lights and power off after the Office mmWave occupancy sensor
# - Turns Office power supplies off after the Office mmWave occupancy sensor
# has been clear for the configured delay period.
#
# - Provides a backup manual control path using the Office spare button.
# This is useful if the occupancy sensor is offline.
#
# Notes:
# - This is treated as a BACKUP automation.
# - The standard method should still be the direct ESPHome/MQTT control path.
# - This HA automation provides a fallback path using HA entity states.
# - This is treated as a BACKUP automation for POWER SUPPLIES ONLY.
# - Light control is handled by direct ESPHome/MQTT (see device YAMLs).
# - The physical spare button is read using:
# binary_sensor.esp_officelights_button_3_spare
# - The spare relay is used as the manual master/latch state:
@@ -36,7 +39,7 @@
input_number:
office_lights_backup_clear_delay_seconds:
name: "Office Lights Backup Clear Delay Seconds"
name: "Office Power Backup Clear Delay Seconds"
min: 0
max: 3600
step: 1
@@ -50,13 +53,14 @@ input_number:
################################################################################
automation:
- id: office_lights_power_backup_occupancy_control
alias: "Office Lights And Power - Backup Occupancy Control"
- id: office_power_backup_occupancy_control
alias: "Office Power - Backup Occupancy Control"
description: >
Backup automation for Office lights and power. Turns required devices on
when Office mmWave occupancy or movement is detected. Turns them off after
the occupancy sensor is clear for the configured delay period. Also allows
Backup automation for Office power supplies. Turns power on when Office
mmWave occupancy or movement is detected. Turns power off after the
occupancy sensor is clear for the configured delay period. Also allows
manual backup toggling using the Office spare button and spare relay.
Light control is handled by direct ESPHome/MQTT sync.
mode: restart
triggers:
##########################################################################
@@ -79,8 +83,8 @@ automation:
# Manual backup button press.
#
# The spare relay state is used as the master/latch:
# - If spare relay is OFF when the button is pressed, turn everything ON.
# - If spare relay is ON when the button is pressed, turn everything OFF.
# - If spare relay is OFF when the button is pressed, turn power ON.
# - If spare relay is ON when the button is pressed, turn power OFF.
##########################################################################
- trigger: state
entity_id: binary_sensor.esp_officelights_button_3_spare
@@ -102,15 +106,15 @@ automation:
- choose:
######################################################################
# ON LOGIC:
# Occupancy detected - turn everything on.
# Occupancy detected - turn power supplies on.
######################################################################
- alias: "Occupancy detected - turn Office lights and power on"
- alias: "Occupancy detected - turn Office power on"
conditions:
- condition: trigger
id: occupancy_detected
sequence:
##############################################################
# Power first.
# Power supplies.
##############################################################
- alias: "Turn on Office ELV power supply if needed"
if:
@@ -132,59 +136,6 @@ automation:
target:
entity_id: switch.esp_officedeskrightgpo_office_right_hand_gpo
#- alias: "Turn on Office USB Hub if needed"
# if:
# - condition: state
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
# state: "off"
# then:
# - action: switch.turn_on
# target:
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
##############################################################
# Lights.
##############################################################
- alias: "Turn on Office right hand bunker light if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
state: "off"
then:
- action: light.turn_on
target:
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
- alias: "Turn on Office cool white overhead lights if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
state: "off"
then:
- action: light.turn_on
target:
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
- alias: "Turn on Office nighttime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_1_nighttime_lights
state: "off"
then:
- action: switch.turn_on
target:
entity_id: switch.esp_officelights_relay_1_nighttime_lights
- alias: "Turn on Office daytime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_2_daytime_lights
state: "off"
then:
- action: switch.turn_on
target:
entity_id: switch.esp_officelights_relay_2_daytime_lights
##############################################################
# Manual master/latch relay.
##############################################################
@@ -200,9 +151,9 @@ automation:
######################################################################
# OFF LOGIC:
# Occupancy clear - wait, re-check, then turn everything off.
# Occupancy clear - wait, re-check, then turn power supplies off.
######################################################################
- alias: "Occupancy clear - wait, re-check, then turn Office lights and power off"
- alias: "Occupancy clear - wait, re-check, then turn Office power off"
conditions:
- condition: template
value_template: >
@@ -229,50 +180,7 @@ automation:
state: "off"
##############################################################
# Lights off first.
##############################################################
- alias: "Turn off Office right hand bunker light if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
state: "on"
then:
- action: light.turn_off
target:
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
- alias: "Turn off Office cool white overhead lights if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
state: "on"
then:
- action: light.turn_off
target:
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
- alias: "Turn off Office nighttime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_1_nighttime_lights
state: "on"
then:
- action: switch.turn_off
target:
entity_id: switch.esp_officelights_relay_1_nighttime_lights
- alias: "Turn off Office daytime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_2_daytime_lights
state: "on"
then:
- action: switch.turn_off
target:
entity_id: switch.esp_officelights_relay_2_daytime_lights
##############################################################
# Power off after lights.
# Power off.
##############################################################
- alias: "Turn off Office right hand GPO if needed"
if:
@@ -294,16 +202,6 @@ automation:
target:
entity_id: switch.esp_officeelvcontrol_office_elv_power_supply
#- alias: "Turn off Office USB Hub power supply if needed"
# if:
# - condition: state
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
# state: "on"
# then:
# - action: switch.turn_off
# target:
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
##############################################################
# Manual master/latch relay off last.
##############################################################
@@ -319,9 +217,9 @@ automation:
######################################################################
# MANUAL BACKUP LOGIC:
# Button pressed while spare relay master is ON - turn everything OFF.
# Button pressed while spare relay master is ON - turn power off.
######################################################################
- alias: "Backup button pressed - spare relay on, turn everything off"
- alias: "Backup button pressed - spare relay on, turn power off"
conditions:
- condition: trigger
id: backup_button_pressed
@@ -330,50 +228,7 @@ automation:
state: "on"
sequence:
##############################################################
# Lights off first.
##############################################################
- alias: "Turn off Office right hand bunker light if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
state: "on"
then:
- action: light.turn_off
target:
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
- alias: "Turn off Office cool white overhead lights if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
state: "on"
then:
- action: light.turn_off
target:
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
- alias: "Turn off Office nighttime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_1_nighttime_lights
state: "on"
then:
- action: switch.turn_off
target:
entity_id: switch.esp_officelights_relay_1_nighttime_lights
- alias: "Turn off Office daytime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_2_daytime_lights
state: "on"
then:
- action: switch.turn_off
target:
entity_id: switch.esp_officelights_relay_2_daytime_lights
##############################################################
# Power off after lights.
# Power off.
##############################################################
- alias: "Turn off Office right hand GPO if needed"
if:
@@ -395,16 +250,6 @@ automation:
target:
entity_id: switch.esp_officeelvcontrol_office_elv_power_supply
#- alias: "Turn off Office USB Hub power supply if needed"
# if:
# - condition: state
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
# state: "on"
# then:
# - action: switch.turn_off
# target:
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
##############################################################
# Manual master/latch relay off last.
##############################################################
@@ -420,12 +265,12 @@ automation:
######################################################################
# MANUAL BACKUP LOGIC:
# Button pressed while spare relay master is OFF - turn everything ON.
# Button pressed while spare relay master is OFF - turn power on.
#
# No off timer is started from this manual press. If the occupancy
# sensor later changes to clear, the normal clear-delay logic will run.
######################################################################
- alias: "Backup button pressed - spare relay off, turn everything on"
- alias: "Backup button pressed - spare relay off, turn power on"
conditions:
- condition: trigger
id: backup_button_pressed
@@ -434,7 +279,7 @@ automation:
state: "off"
sequence:
##############################################################
# Power first.
# Power supplies.
##############################################################
- alias: "Turn on Office ELV power supply if needed"
if:
@@ -456,59 +301,6 @@ automation:
target:
entity_id: switch.esp_officedeskrightgpo_office_right_hand_gpo
# alias: "Turn on Office USB Hub power supply if needed"
# if:
# - condition: state
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
# state: "off"
# then:
# - action: switch.turn_on
# target:
# entity_id: switch.esp_officeusbhubpower_usb_hub_power_supply
##############################################################
# Lights.
##############################################################
- alias: "Turn on Office right hand bunker light if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
state: "off"
then:
- action: light.turn_on
target:
entity_id: light.esp_officeduallights_light_1_right_hand_bunker_light
- alias: "Turn on Office cool white overhead lights if needed"
if:
- condition: state
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
state: "off"
then:
- action: light.turn_on
target:
entity_id: light.esp_officeduallights_light_2_cool_white_overhead_lights
- alias: "Turn on Office nighttime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_1_nighttime_lights
state: "off"
then:
- action: switch.turn_on
target:
entity_id: switch.esp_officelights_relay_1_nighttime_lights
- alias: "Turn on Office daytime lights relay if needed"
if:
- condition: state
entity_id: switch.esp_officelights_relay_2_daytime_lights
state: "off"
then:
- action: switch.turn_on
target:
entity_id: switch.esp_officelights_relay_2_daytime_lights
##############################################################
# Manual master/latch relay.
##############################################################