fix: Front door presence does not get cleared properly
This commit is contained in:
@@ -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}");
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user