Switch On & Off Sitecom WLC-1000 Camera Motion detection with openhab

Recently I bought some Sitecom WLC-1000 Cameras on sale for a great price, they are quite good for indoors, but the software isn’t that great, for instance I can set to enable record on motion detection through the mobile app, but I can’t specify any time range for this…
I don’t want the cams recording all day when I’m home, because they will keep sending notifications every minute, and I don’t want to manually disable and enable 3 cams when I get home or leave home…

After some digging I found the settings urls for the camera, and since I have an alarm switch set in openhab, which takes care of alerting when movement is detected, and switching on all lights, I will make a short tutorial on how to enable motion / audio detection through openhab rules, so my cameras will enable motion_detection when the alarm is on, and disable when off.

The url where you need to post your settings:

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>3</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
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

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:

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>

More information on the sitecom cameras:
https://www.thomaslang.nl/sitecom-wlc-1000-review-api-endpoints/