Implements a translation layer between camera interfaces (ONVIF, ad-hoc HTTP APIs, etc) and MQTT.
Some ONVIF software libraries are prone to reliability problems. If a camera goes offline for a while, the library won't know the camera is offline and won't recover nor fail (e.g. letting docker-compose restart the container). Moreover, some programs don't release resources reserved on the cameras (like ONVIF subscriptions) which can cause random connection problems on some cameras. These are severe problems for a security/alarm system that this software aims to solve.
This program is designed with reliability in mind. Every component is independent and tries to recover by itself if any problem happens.
For now, only two modules are implemented:
Feel free to try other cameras and let me know if it works so I can update this list.
A precompiled docker image is available on docker hub.
image: acasal/cam2mqtt:latest
Use the included docker-compose.yml and the example config file config.example.yml as a template to create your config file.
$ docker-compose up
NOTE: if you don't use the ONVIF webHook subscription method, you can remove the port
section on docker-compose.yml
.
$ sbt compile stage
\
The resulting binaries will be located at target/universal/stage
$ CONFIG=./my_config_file.yml sbt
\
sbt:cam2mqtt> run
Check the MQTT protocol on this page.
motion on
event from my Reolink cameraSome cameras like RLC-410W and E1 Zoom don't send the motion: off
event, so it should be generated by software.
To fix this issue, add this setting to your camera onvif module config.
onvif:
force_motion_debounce_time: 2 seconds
Adjust the time to fit your camera. A value between 1-3 seconds should be enough.
This feature is only available on "A" Reolink cameras.
Reolink cameras have 2 ways to communicate AI detection state.
>= 3.1.0.951, april 2022
. Most of the cameras don't have this firmware available as of December 2022.For cameras on firmware < 3.1.0.951, april 2022
you should use the reolink
module with option ai_detection_mode: on_motion
if using it in conjunction with onvif
module (recommended), or ai_detection_mode: continuous
if not using the onvif
module.
For cameras on firmware >= 3.1.0.951, april 2022
, if using reolink
module you should set ai_detection_mode: off
(default behavior).
Check this Reolink firmware repository for and updated firmware for your Reolink camera.
Copyright 2023 Arturo Casal
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.