hjdhjd / homebridge-unifi-protect

:video_camera: Complete HomeKit integration for all UniFi Protect device types with full support for most features including HomeKit Secure Video, and more. https://homebridge.io
Other
1.43k stars 88 forks source link

MQTT - Doorbell Message never set back to 'false' #594

Closed nkringle closed 2 years ago

nkringle commented 2 years ago

Describe The Problem: Firstly, I don't know if this is a bug or if it should be a feature request. Basically, I am using the MQTT topics to get metrics into prometheus/grafana. (I'm creating a dashboard for the number of vehicles driving/people walking/doorbell rings.) In the case of motion and smart detections, the MQTT topic is set to true when the event fires from the doorbell, and is set back to false (and an MQTT event is fired) after the defined event timeout (motionDuration). The doorbell does not set the topic back to false.

This specific inconsistency is where I am wondering if this is a bug, or a feature. :)

To Reproduce: With a G4 doorbell, Homebridge, MQTT enabled and publishing to a topic, and listening to a topic, ring the door bell and observe that the MQTT topic unifi/protect/<Mac>/doorbell is set to true and never reset. Trigger a motion event and observe that the MQTT topic unifi/protect/<Mac>/motion is set to true and then is set to false after the motionDuration timeout. Trigger a smart motion detection event (person or vehicle) and observe that the MQTT topic unifi/protect/<Mac>/motion/smart/vehicle is set to true and then is set to false after the motionDuration timeout.

Logs: Logs from Homebridge are not applicable in this situation.

Logs are not applicable or necessary in this situation.

Homebridge Configuration:

        {
            "controllers": [
                {
                    "address": "192.168.x.x",
                    "mqttUrl": "mqtt://192.168.x.x",
                    "name": "UDM-Pro",
                    "password": "removed",
                    "refreshInterval": 10,
                    "username": "removed"
                }
            ],
            "motionDuration": 5,
            "platform": "UniFi Protect"
        },

Screenshots: Doorbell MQTT: (Notice the history tab - the topic is set to true and never set back to false.)

Screen Shot 2021-12-01 at 10 23 04 PM

Smart Vehicle MQTT Topic: (Notice the history tab - after 5 seconds the topic value is set back to false.)

Screen Shot 2021-12-01 at 10 24 56 PM

Environment:

hjdhjd commented 2 years ago

It’s working exactly as designed. The inconsistency is unintentional, but serves a purpose.

The ring event can be fired multiple times in rapid succession, the motion event can’t be - there’s an enforced time duration in between motion detection events, for instance. Doing a rapid series of ring on/off events would be confusing - so we only inform when the ring event occurs. Creating a mechanism to deal with duplicates is up to you on the MQTT end.

Hope this helps shed a little light on it.

nkringle commented 2 years ago

That's fine - I wasn't sure and figured I'd ask before I put a lot of work into dealing with it on the MQTT side. Thanks for the quick response!

hjdhjd commented 2 years ago

Of course. Thanks for reaching out.

github-actions[bot] commented 1 year ago

This issue is locked to prevent necroposting on closed issues. Please create a new issue for related support requests, bug reports, or feature suggestions.