Openhab 2 Rules & Sitecom WLC-1000 Camera Script

I have openhab running as my home automation system, which allows me to control my lights and in-house ventilation system. And I have setup some nice rules to automate as much as possible, now I want to update my WLC-1000 cameras settings through openhab.

21989622_3824

Recently I bought some Sitecom WLC-1000 Cameras in a sale on iBOOD for a great price, I will make a short review and some dissecting / exploring them in another post.

Bottom line is, they are quite good for indoors, but the software isn’t that great, for instance I can set to enable motion detection, but I can’t specify any time range for this (I don’t want the cams recording all day, because they will keep sending notifications every minute, when movement is detected (or sound if you enable it.), and I don’t want to need to enable motion on every single cam every night / morning when away..

After some digging and playing around I found you can post setting strings to this url:
http://<IP_OF_YOUR_CAM>/CGI/CameraSetup
the settings to enable motion detection through posting an xml:

<Item><MOTION_DETECTION><ENABLE>ON</ENABLE><SENSITIVITY>3</SENSITIVITY></MOTION_DETECTION></Item>

and to disable:

<Item><MOTION_DETECTION><ENABLE>OFF</ENABLE><SENSITIVITY>0</SENSITIVITY></MOTION_DETECTION></Item>

I created 2 simple python files, which I can later execute in openhab when certain conditions are met.
The turn motion detection on file:

# -*- coding: utf-8 -*-
import requests

xml = """<Item><MOTION_DETECTION><ENABLE>ON</ENABLE><SENSITIVITY>3</SENSITIVITY></MOTION_DETECTION></Item>"""
headers = {'Content-Type': 'application/xml'}
print requests.post('http://YOUR_CAM_IP/CGI/CameraSetup', data=xml, headers=headers).text

In order to test this in openhab, I created a switch in my cam.items file

Switch enableCams

and created a cams.rules file, which has:

rule "Switch On Motion Recording"
	when 
		Item enableCams received command ON
	then
		val result = executeCommandLine("python /home/openhabian/python/alarm_on.py",2000)
		logInfo("Switching on motion detection", result)
end

I added some logging to check the response from the cam in my openhab eventlog (/var/log/openhab2/openhab.log) and sure enough there it is:

terminal

If you would like to enable audio detection in the same way, just replace the xml with:

<Item><AUDIO_DETECTION><ENABLE>ON</ENABLE><SENSITIVITY>3</SENSITIVITY></AUDIO_DETECTION></Item>

I will follow up with more info on the sitecom’s camera settings in a later post.

Leave a Reply

Your email address will not be published.