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.39k stars 84 forks source link

MQTT sensor auto publish ? #1052

Closed tablatronix closed 3 months ago

tablatronix commented 3 months ago

Describe the feature request

Would it be possible to add a setting for sensors to auto publish sensor metrics?, I currently have to run mac/attrib/get requests for each sensor x each attribute.

unifi/protect/9C05D63EF008/ambientlight/get polling

Describe the proposed solution

Add a mqtt autopublish period in settings, or detect updates from protect and trigger.

Describe alternatives you have considered to the enhancement

or easier perhaps, Add a local mqtt loopback timer with a user input for all the topics, and call that internally.

-- topics to publish 1 per line
unifi/protect/9C05D63EF008/ambientlight/get
unifi/protect/9C05D63EF008/temperature/get
...
-- interval(s)
600

If I missing something obvious to do this, right now using nodered timers

tablatronix commented 3 months ago

Now it seems to be publishing, strange, I guess I was mistaken, nothing was coming through before..

github-actions[bot] commented 3 months 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.

hjdhjd commented 3 months ago

Events are always published in realtime in HBUP. You never need to poll, it's there as a convenience for certain point-in-time use cases and for standardization reasons. HBUP always publishes events in realtime as they occur. If a UniFi Protect Sensor publishes updated information (which they tend to do every so often), that information is published immediately.

the /get is if you need immediate access to a value for a particular purpose, rather than waiting for the next event whenever it occurs. It's useful say when you startup some listener to the MQTT topic, as an example, and want to initialize the value.