From 78705d440a67208b492b374d293e74adeb2ee7da Mon Sep 17 00:00:00 2001 From: JakeHillion Date: Sat, 25 May 2024 22:03:11 +0100 Subject: [PATCH] homeassistant: only switch bathroom light when it is already on Although the system now knows whether the bathroom light is on, it switches the switch every time the light should be turned off regardless of if it's already off. Because this is a device running on battery that performs a physical movement this runs the battery out very fast. Adjust the system to only switch the light off if it thinks it's on, even though this has the potential for desyncs. --- modules/services/homeassistant.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/services/homeassistant.nix b/modules/services/homeassistant.nix index 3f3977e..19ecf0c 100644 --- a/modules/services/homeassistant.nix +++ b/modules/services/homeassistant.nix @@ -116,10 +116,7 @@ in unique_id = "87a4cbb5-e5a7-44fd-9f28-fec2d6a62538"; value_template = "{{ states('sensor.bathroom_motion_sensor_illuminance_lux') | int > 500 }}"; turn_on = { service = "script.noop"; }; - turn_off = { - service = "switch.turn_on"; - entity_id = "switch.bathroom_light"; - }; + turn_off = { service = "script.bathroom_light_switch_if_on"; }; }; }; }