ratgdo / mqtt-ratgdo

ratgdo via mqtt
GNU General Public License v2.0
76 stars 16 forks source link

Motion flag is never cleared #63

Closed Goose66 closed 5 months ago

Goose66 commented 5 months ago

Posting a new issue because I see the previous one was closed with no apparent resolution.

This issue is not related to the updating of light status upon detecting motion. Instead, this issue is about the fact that once a motion status message is published with "detected," the status message is never reset to "clear." Going through the code, while the internal motion flag itself is set to clear (0) each time through the status loop (and several other places), there are no times when setting the motion flag to 0 results in a "clear" MQTT message being published. A message is only published when the motion flag is set to 1 ("detected"). What's more, it is published as a retained message, so the status in the MQTT broker will always return "detected" if it is queried or on new subscriptions, whether there is motion or not.

IMO, it should be either 1) managed like the other statuses with a previousMotionState and clear and detected messages posted each time it changes, or 2) should not be retained message with "detected" messages published only when motion is detected (and thus we would never expect a "clear" status).

PaulWieland commented 5 months ago

It's not supposed to be. The panel doesn't clear motion (and neither do any other PIRs Ive worked with). They just send a signal when motion is detected.

Goose66 commented 5 months ago

Fair enough. How about changing the retention flag on the Matt public to false?

Goose66 commented 5 months ago

Wow, iPhone autocorrect on GitHub is problematic! That was supposed to be changing the retention flag on MQTT publish to false 😀