Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send mqtt message when motion is detected #3152

Merged

Conversation

NickM-27
Copy link
Sponsor Collaborator

Adds a motion topic that can be used as a generic motion detector.

@NickM-27
Copy link
Sponsor Collaborator Author

Currently seeing an issue where the publish never goes through, wondering if passing the mqtt_client through the process to another thread could be what is causing the issue? Will have to keep digging.

@blakeblackshear
Copy link
Owner

You can't pass the mqtt client to a separate process like this. It would need to be handled in object_processing.py along with the other mqtt sensors.

@NickM-27
Copy link
Sponsor Collaborator Author

You can't pass the mqtt client to a separate process like this. It would need to be handled in object_processing.py along with the other mqtt sensors.

Awesome, ended up being a lot cleaner as well!

@hawkeye217
Copy link
Collaborator

hawkeye217 commented Apr 27, 2022

What do you think about adding an optional config option under the mqtt: section for each camera to enable or disable this? It'd be nice to be able to mitigate excess mqtt traffic in case someone doesn't need the feature.

Edit: on second thought, it may not be necessary... There's lots of traffic already from HA sensors that can't easily be mitigated...

@NickM-27
Copy link
Sponsor Collaborator Author

What do you think about adding an optional config option under the mqtt: section for each camera to enable or disable this? It'd be nice to be able to mitigate excess mqtt traffic in case someone doesn't need the feature.

Edit: on second thought, it may not be necessary... There's lots of traffic already from HA sensors that can't easily be mitigated...

I think it would need to be added to a messages section underneath mqtt if it were to be added. I already have the code setup such that it shouldn't send redundant messages with the same state, so I am not sure how much extra traffic this will add especially with the default 30 seconds off timeout.

@hawkeye217
Copy link
Collaborator

I already have the code setup such that it shouldn't send redundant messages with the same state, so I am not sure how much extra traffic this will add especially with the default 30 seconds off timeout.

Right. I think it should be good then.

@NickM-27
Copy link
Sponsor Collaborator Author

NickM-27 commented May 1, 2022

Just as a point of reference, here is MQTT explorer showing the sensor working as expected:

Screen Shot 2022-05-01 at 11 19 58 AM

@blakeblackshear
Copy link
Owner

Don't the other sensors publish ON and OFF?

@NickM-27
Copy link
Sponsor Collaborator Author

NickM-27 commented May 12, 2022

Don't the other sensors publish ON and OFF?

That's for the switches / toggles though, I don't believe we have any other sensors that publish a state so I was thinking "motion/detected = ON" wasn't as intuitive, but I don't feel strongly so if the consistency is better, thenON works for me as well

@NickM-27
Copy link
Sponsor Collaborator Author

@blakeblackshear after thinking about it a bit more I can think of 3 good options:

  1. Keep it as it is now: /motion/detected = True/False
  2. Change it to /motion/detected = ON/OFF
  3. Change it to /motion/status = DETECTED/CLEAR

let me know what you think 👍

@blakeblackshear
Copy link
Owner

If it will translate to an mqtt binary sensor in home assistant, I would prefer to stick the default expected payloads. That's why ON/OFF have been used historically. https://www.home-assistant.io/integrations/binary_sensor.mqtt/

docs/docs/configuration/index.md Outdated Show resolved Hide resolved
frigate/object_processing.py Outdated Show resolved Hide resolved
frigate/object_processing.py Outdated Show resolved Hide resolved
@blakeblackshear blakeblackshear merged commit de244d6 into blakeblackshear:release-0.11.0 May 15, 2022
@NickM-27 NickM-27 deleted the mqtt-motion-detector branch May 30, 2022 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants