Openhab

From ZoneMinder Wiki
Revision as of 10:10, 2 September 2023 by Biloxigeek (talk | contribs) (→‎Switch PTZ camera between night/day modes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Openhab

Looking to work up some documention for integrating zoneminder and openhab.

Tasks

  • Getting the openhab binding for zoneminder working
    • Got the bridge working, had to get a Let's Encrypt certificate working on the zoneminder apache setup since I wanted to keep it working https only
  • Setting up things/items in openhab that will link image and video streams into openhab
    • The monitors populate pretty easily. I haven't gotten the image or video URLs working yet.
  • Rules that can be triggered from events in openhab to cause zoneminder functions
    • Example: door open sensor turns light on and causes a zoneminder monitor to start recording for a specified period of time

Notes

I'm just starting down this path myself and wanted to document my efforts so it might be a bit easier for others in the future

Executing local scripts

Some scripting ideas:

Switch PTZ camera between night/day modes

executeCommandLine(Duration.ofSeconds(10), "/etc/openhab/bin/set_zm_camera_day.sh")


That script connects to the zoneminder server over ssh using an RSA key for authentication and runs /root/bin/set_camera_day.sh:

#!/usr/bin/bash

# Turn off nightime zone
/root/bin/get_zones.pl -s inactive -z zone-camera-night-preset

# move camera to day preset
/usr/bin/zmcontrol.pl --id 100 --command="presetGoto" --preset 3

# Make sure the camera move has time to complete
sleep 5

# Turn on nighttime zone
/root/bin/get_zones.pl -s active -z zone-front-day-preset
  • This seems to be working pretty well. Requires ssh keys so the openhab user can login to zoneminder server. If zm and openhab were on the same server that would be easier.
  • A second script on both systems that does the opposite, turns the day zone to inactive, moves the camera to it's night setting and then activates the night zone