feat: Added automation for wardrobe light
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user