refactor: Split config
Some checks failed
Build and deploy / Deploy container (push) Blocked by required conditions
Build and deploy / build (push) Has been cancelled

This commit is contained in:
2025-10-20 04:39:12 +02:00
parent 3f61ec7252
commit 40776ffe4c
20 changed files with 1083 additions and 756 deletions

42
config/light.lua Normal file
View File

@@ -0,0 +1,42 @@
local devices = require("automation:devices")
local helper = require("config.helper")
local module = {}
--- @class OnPresence
--- @field [integer] fun(light: boolean)
local callbacks = {}
--- @param callback fun(light: boolean)
function module.add_callback(callback)
table.insert(callbacks, callback)
end
--- @param _ DeviceInterface
--- @param light boolean
local function callback(_, light)
for _, f in ipairs(callbacks) do
f(light)
end
end
--- @type LightSensor?
module.device = nil
--- @type SetupFunction
function module.setup(mqtt_client)
module.device = devices.LightSensor.new({
identifier = "living_light_sensor",
topic = helper.mqtt_z2m("living/light"),
client = mqtt_client,
min = 22000,
max = 23500,
callback = callback,
})
return {
module.device,
}
end
return module