fix: Front door presence does not get cleared properly

This commit is contained in:
2025-09-08 04:01:16 +02:00
parent 5383e7265d
commit 1925bac73c
2 changed files with 8 additions and 2 deletions

View File

@@ -28,7 +28,13 @@ impl mlua::UserData for WrappedAsyncClient {
methods.add_async_method(
"send_message",
async |_lua, this, (topic, message): (String, mlua::Value)| {
let message = serde_json::to_string(&message).unwrap();
// serde_json converts nil => "null", but we actually want nil to send an empty
// message
let message = if message.is_nil() {
"".into()
} else {
serde_json::to_string(&message).unwrap()
};
debug!("message = {message}");

View File

@@ -520,7 +520,7 @@ setmetatable(frontdoor_presence, {
end
else
self.timeout:start(debug and 10 or 15 * 60, function()
mqtt_client:send_message(mqtt_automation("presence/contact/frontdoor"), {})
mqtt_client:send_message(mqtt_automation("presence/contact/frontdoor"), nil)
end)
end
end,