From 5a2c1b0a13597bdc62b53b6ecb99788d1b9df7bc Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 12 May 2026 04:27:46 +0200 Subject: [PATCH] feat: Added automation for wardrobe light --- config/rooms/bedroom.lua | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/config/rooms/bedroom.lua b/config/rooms/bedroom.lua index 42bf2a5..e004e39 100644 --- a/config/rooms/bedroom.lua +++ b/config/rooms/bedroom.lua @@ -25,6 +25,13 @@ function module.setup(mqtt_client) group_id = 3, scene_id = "60tfTyR168v2csz", }) + local wardrobe_light = devices.HueGroup.new({ + identifier = "bedroom_lights_wardrobe", + ip = hue_bridge.ip, + login = hue_bridge.token, + group_id = 3, + scene_id = "1IDvpsN2YLZsDV95", + }) air_filter = devices.AirFilter.new({ name = "Air Filter", @@ -32,13 +39,36 @@ function module.setup(mqtt_client) url = "http://10.0.0.103", }) + local wardrobe_door = devices.ContactSensor.new({ + name = "Wardrobe Door", + room = "Bedroom", + sensor_type = "Door", + topic = helper.mqtt_z2m("bedroom/wardrobe_door"), + client = mqtt_client, + callback = function(_, open) + -- Technically this has an edge case where if one of the spots is + -- on, but that is not something I ever do + if not lights:all_on() then + wardrobe_light:set_on(open) + end + end, + battery_callback = battery.callback, + }) + local switch = devices.HueSwitch.new({ name = "Switch", room = "Bedroom", client = mqtt_client, topic = helper.mqtt_z2m("bedroom/switch"), left_callback = function() - lights:set_on(not lights:on()) + local on = not lights:all_on() + lights:set_on(on) + -- This is a bit janky as the light will start to dim before turning + -- back on, however this is really and edge case that probably won't + -- happen often, so for now it's fine + if not on and wardrobe_door:open_percent() == 100 then + wardrobe_light:set_on(true) + end end, left_hold_callback = function() lights_relax:set_on(true) @@ -61,6 +91,7 @@ function module.setup(mqtt_client) lights, lights_relax, air_filter, + wardrobe_door, switch, window, },