Compare commits
3 Commits
feature/im
...
b547f66d86
| Author | SHA1 | Date | |
|---|---|---|---|
|
b547f66d86
|
|||
|
f3de8e36ea
|
|||
|
44f2c57819
|
@@ -21,5 +21,7 @@ RUN cargo auditable build --release
|
|||||||
|
|
||||||
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
||||||
COPY --from=builder /app/target/release/automation /app/automation
|
COPY --from=builder /app/target/release/automation /app/automation
|
||||||
|
ENV AUTOMATION__ENTRYPOINT=/app/config/config.lua
|
||||||
|
ENV LUA_PATH="/app/?.lua;;"
|
||||||
COPY ./config /app/config
|
COPY ./config /app/config
|
||||||
CMD [ "/app/automation" ]
|
CMD [ "/app/automation" ]
|
||||||
|
|||||||
@@ -25,10 +25,18 @@ function module.setup(mqtt_client)
|
|||||||
})
|
})
|
||||||
windows.add(window)
|
windows.add(window)
|
||||||
|
|
||||||
|
local printer = devices.OutletOnOff.new({
|
||||||
|
name = "3D Printer",
|
||||||
|
room = "Guest Room",
|
||||||
|
topic = helper.mqtt_z2m("guest/printer"),
|
||||||
|
client = mqtt_client,
|
||||||
|
})
|
||||||
|
|
||||||
--- @type Module
|
--- @type Module
|
||||||
return {
|
return {
|
||||||
light,
|
light,
|
||||||
window,
|
window,
|
||||||
|
printer,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -59,26 +59,21 @@ function module.setup(mqtt_client)
|
|||||||
})
|
})
|
||||||
hallway_automation.set_trash(trash)
|
hallway_automation.set_trash(trash)
|
||||||
|
|
||||||
---@param duration number
|
local timeout = utils.Timeout.new()
|
||||||
---@return fun(_, open: boolean)
|
local function frontdoor_presence(_, open)
|
||||||
local function frontdoor_presence(duration)
|
if open then
|
||||||
local timeout = utils.Timeout.new()
|
timeout:cancel()
|
||||||
|
|
||||||
return function(_, open)
|
if not presence.overall_presence() then
|
||||||
if open then
|
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), {
|
||||||
timeout:cancel()
|
state = true,
|
||||||
|
updated = utils.get_epoch(),
|
||||||
if presence.overall_presence() then
|
})
|
||||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), {
|
|
||||||
state = true,
|
|
||||||
updated = utils.get_epoch(),
|
|
||||||
})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
timeout:start(duration, function()
|
|
||||||
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), nil)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
timeout:start(debug.debug_mode and 10 or 15 * 60, function()
|
||||||
|
mqtt_client:send_message(helper.mqtt_automation("presence/contact/frontdoor"), nil)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -89,7 +84,7 @@ function module.setup(mqtt_client)
|
|||||||
topic = helper.mqtt_z2m("hallway/frontdoor"),
|
topic = helper.mqtt_z2m("hallway/frontdoor"),
|
||||||
client = mqtt_client,
|
client = mqtt_client,
|
||||||
callback = {
|
callback = {
|
||||||
frontdoor_presence(debug.debug_mode and 10 or 15 * 60),
|
frontdoor_presence,
|
||||||
hallway_automation.door_callback,
|
hallway_automation.door_callback,
|
||||||
},
|
},
|
||||||
battery_callback = battery.callback,
|
battery_callback = battery.callback,
|
||||||
|
|||||||
Reference in New Issue
Block a user