Skip to content

Fix MQTT publish for built-in motion detections#440

Merged
matteius merged 1 commit into
opensensor:mainfrom
yangs1202:fix-motion-mqtt-publish
Jun 14, 2026
Merged

Fix MQTT publish for built-in motion detections#440
matteius merged 1 commit into
opensensor:mainfrom
yangs1202:fix-motion-mqtt-publish

Conversation

@yangs1202

Copy link
Copy Markdown
Contributor

Summary

  • publish MQTT detection payloads for built-in motion detections
  • update Home Assistant motion and detection count topics from the built-in motion backend
  • keep behavior aligned with API and ONVIF detection paths

Why

The built-in motion detection path stores thresholded detections in the database, but unlike the API detection path it did not call mqtt_publish_detection() or mqtt_set_motion_state(). As a result, Home Assistant discovery topics were created, snapshots continued to publish, but these state topics did not update for streams using model=motion:

  • lightnvr/cameras/<stream>/motion
  • lightnvr/cameras/<stream>/detection_count
  • lightnvr/detections/<stream>

Testing

  • Applied the patch to a clean clone.
  • Ran git diff --check.
  • Built in a Debian sid container with CI-like options:
    cmake .. \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
      -DENABLE_SOD=OFF \
      -DENABLE_GO2RTC=OFF \
      -DBUILD_TESTS=OFF
    cmake --build . -j2
  • Confirmed build/bin/lightnvr was produced.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to lightNVR! 🎉

Before we can merge your pull request, we need you to sign our Contributor License Agreement (CLA).

Why a CLA?
lightNVR uses a dual-licensing model. While the project is freely available under GPLv3, OpenSensor Engineering also offers commercial licenses. The CLA ensures we can continue offering both options.

To sign the CLA, please reply to this comment with exactly:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once, and it applies to all future contributions.


ℹ️ More about the CLA

The CLA grants OpenSensor Engineering the right to:

  • Include your contributions under GPLv3 (open source)
  • Offer commercial licenses that include your contributions

You retain copyright of your contributions and can use them in other projects.

- - - I have read the CLA Document and I hereby sign the CLA - - - You can retrigger this bot by commenting **recheck** in this Pull Request. Posted by the **CLA Assistant Lite bot**.

@matteius matteius merged commit b89fe80 into opensensor:main Jun 14, 2026
1 check failed
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.

2 participants