So for the past years, one of my little sideprojects was a little tinkering with home automation. Five years ago i started all this with a Raspberry Pi, an Arduino Duemillanove and some high voltage photocouplers. One of the first things I did was making my electric door opener available on the internet. For that I scripted a bash code into php which injected parameters into an Arduino sketch which was basically just switching on the 5V pins. The 5V pins then were connected to the control pins of the photocoupler, effectively switching on the door opener. I edited the script to just buzz the door for 5 seconds and then switching back off. Over the years I experimented more and more. But everything I did was very stressful since I had to program everything myself. I am now in the process of restructuring everything to make things more simple.
For my new journey I chose a completely new environment. I am running a Raspberry Pi 3 with the latest Raspbian now. On it, several services such as PiAware, fr24feed, dump1090-mutability, Zoneminder for CCTV and of course – the new heart of my smart home – openHAB2.
On my openHAB2 installation, I have the following addons:
- Telegram Action
- Astro Binding
- Exec Binding
- Network Binding
- Samsung TV Binding
- Weather Binding
- Zoneminder Binding
- Google Calendar Scheduler
- OpenHAB Cloud Connector
- Experimental Rule Engine
- MapDB Persistence
- Exec Transformation
- Map Transformation
- Regex Transformation
- Basic UI
Of course I am not yet using every single addon I listed above. But I potentially will some day.
One of the biggest step to take is to just do it. You will only learn the logic behind everything, if you are trying and failing. It’s a challenge to find out what’s possible and to get ones head around it. I started automating a Zoneminder monitor.
I am running Zoneminder with a monitor I want to stop capturing when I am home. It is using Modect so it is capturing video to disk as soon as it’s detecting movement.
Okay so basically the whole thing consists of two rules.
- If the network binding detects my phone in my home network (arping) – set the enabled flag on the monitor to on.
- If the network binding doesn’t detect my phone in my home network (arping) – set the enabled flag on the monitor to off.
You see, this is pretty easy. But wait. There were problems.
Without any problems, experiments like these are only half the fun, right? Since I followed the tutorials on the openHAB website, I expected things to work out of the box but I was failed.
So what was the problem?
For some reason, my Zoneminder bridge didn’t connect. openHAB wasn’t able to use it and pull my monitors and kept showing Offline.
The error message in the log was:
[ERROR] [andler.ZoneMinderServerBridgeHandler] – [BRIDGE (6c7724e0)]: Exception occurred in updateAvailabilityStatus Exception=’null’
After switching on the OPT_USE_API option in the Zoneminder interface, my error message changed to:
[ERROR] [andler.ZoneMinderThingMonitorHandler] – [MONITOR-4]: Bridge ‘null’ is OFFLINE
[ERROR] [andler.ZoneMinderServerBridgeHandler] – [BRIDGE (67b4af5d)]: Exception occurred in updateAvailabilityStatus Exception=’null’
[INFO ] [r.handler.ZoneMinderBaseThingHandler] – [MONITOR-4]: Thing status changed from ‘OFFLINE’ to ‘OFFLINE’ (DetailedStatus=’BRIDGE_OFFLINE’, Description=’Bridge ‘null’ is OFFLINE’)
I then tried to curl the api URL as stated in the troubleshooting guide of the zoneminder binding.
curl -d “username=XXXX&password=YYYY&action=login&view=console” -c cookies.txt http:///zm/index.php.
I received the website and it showed me the correct permissions on both my client workstation and on the openHAB server so my error was to be found somewhere else. The hint I needed was the API endpoint.
Let’s say your Zoneminder is installed to http://zoneminderIP/zm – this means your api is at http://zoneminderIP/zm/api. If you call this URL you should see the CakePHP interface. If there are errors on there, fix those and the Zoneminder binding will work!
In my case it was a missing mod rewrite in apache. Installing this and restarting the webserver fixed the whole thing for me.