IpCamera: New IP Camera Binding

The above gives you smooth video streaming? Or is it just an image refreshed every second so it’s “jerkey”?

It gives u smooth video With cameras that are listed in the readme. A note on port 101 is that under Linux it needs higher rights to be used, the binding should be warning you of this if you read the logs. Try a port much higher up and that may be the cause.

the binding is working well, except i get a lot of
2019-10-10 09:51:46.704 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - ipCamera restarting.
and
2019-10-10 10:09:12.734 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm stream was not running for camera 192..1., re-starting it now
any ideas?

the thing file–>

Thing ipcamera:HIKVISION:Woonkamer “Woonkamer” @ “Cameras”
[
IPADDRESS=“...“,
PASSWORD=”
******”,
USERNAME=“*****”,
POLL_CAMERA_MS=5000,
SERVER_PORT=80
]

Camera.items
Switch Camera_Woonkamer_PIR “Beweging in woonkamer” {channel=“ipcamera:HIKVISION:Woonkamer:pirAlarm”}

paperUI
image

@matt1
where can i find the enable/disable PIR alarm?
Like you have for the Enable/Disable the Line Crossing Alarm?


If i use PostMan i can modify the xml by passing a raw xml to the body

I am trying to implement this myself, but i ran into some trouble…
I have made a rule where i want to do the same using curl, but i get following error in the log

2019-10-11 00:33:08.136 [INFO ] [.eclipse.smarthome.model.script.test] - curl: (3) Port number ended with '\'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0   178    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100   293  100   293    0     0    293      0  0:00:01 --:--:--  0:00:01   293
<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/WLAlarm/PIR</requestURL>
<statusCode>3</statusCode>
<statusString>Device Error</statusString>
<subStatusCode>deviceError</subStatusCode>
</ResponseStatus>

my guess is that the content in my PIR_Sensor_OFF.xml file is causing the error.(syntax mistakes?)

In my rule file

var String tst = “curl -H Content-Type:application/xml -X PUT C:\openhab-2.4.0\conf\html\pir\PIR_Sensor_OFF.xml http://192.168.1.201/ISAPI/WLAlarm/PIR/ --user admin:****** --anyauth”

var String response = executeCommandLine(tst, 1000)

In the PIR_SENSOR_OFF.xml file i have

<?xml version="1.0" encoding="UTF-8"?>
<PIRAlarm version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
    <enabled>false</enabled>
    <name>Hal PIR</name>
</PIRAlarm>

If you have it working via postman or curl via the terminal, then provide the details to me on what needs to be sent and I can then implement into the binding so everyone then gets an easy to use solution. Not everything in the API is implemented because people have not requested the feature and since I do this for free and not paid I only add things that will get used and also I need people to test as my cameras do not have PIR in them.

I am pretty sure that will create issues as 80 is possibly in use and also lower ports need higher rights to open in linux, choose another port higher than 2000 that is not in use by anything else.

POSTMAN:
When you do a GET to http://[IPADDRESS_CAMERATHING]/ISAPI/WLAlarm/PIR
then you will get an xml with the current state of the PIR is enable or disabled

<?xml version="1.0" encoding="UTF-8"?>
<PIRAlarm version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
    <enabled>false</enabled>
    <name>Hal PIR</name>
</PIRAlarm>

When you do a PUT in postman you have to send an xml format like in the picture above with
<enabled>false</enabled> or <enabled>true</enabled>

image

If it is sended you will get a return result also in an xml format

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/WLAlarm/PIR</requestURL>
<statusCode>2</statusCode>
<statusString>Success</statusString>
</ResponseStatus>

So in openHAB we will need a Switch like this one:
image

1 Like

@matt1 is it clear my explanation?
this person has the same solutions

Hi @matt1 !
Thanks for the binding, it works like a charm. One thing I want to ask though. My OH setup is on Pi and have an esp32 cam and PIR for motion detection. Image is taken whenever there is motion.
How to save the images taken to a location on pi, on a usb flash drive for instance?

Hi again.
I was going through the binding code.
Can you please add an option to store snapshot when update Image event takes place. That would be very helpful for some people like me who would like to use that to save images to an external flash drive.

You can use the create gif feature for that see readme for more info on this and how it creates static pictures as well.

1 Like

Yes that is all the info I need, it is just finding some time to spare to do it. The framework to do that is already in place so it only half hour work to add after I get the ide running again.

1 Like

looking forward to it. Thnx in advance!

@matt1 Yes I have already tried the gif feature. It works well. The thing is , it only stores number of pictures given as postroll and on top of that produces a gif as well which is not required by me.
It would be better to have a separate option to store images to a directory whenever update Image event occurs.In image names, adding timestamp would be awesome.
It would suit my use case where I have a PIR sensor which activates a rule to turn on update image and once image is updated, another rule turns off update Image.If the images taken are also saved, it would be a cheap NVR alternative.

Someone posted a copy of their rule on this forum on how to take the image items state and create a jpg file. Easy to do what you want with a rule.

1 Like

@matt1 Thanks a lot. That could make my life easier.

Hi, thanks for this binding. Having a couple issues, I’m trying to work thru. Just looking to have a few cameras display on my sitemap (for now). I have 3 cams that work great (HIKVISION and FOSCAM), but having trouble with another (a SV3C oddball brand, HX series).

Setting up the Thing via Paper UI. I can get the camera to show as Online in Paper as a ONVIF type, but after entering camera data initially, I get:

Status: OFFLINE - CONFIGURATION_ERROR Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

If I enter a valid URL in the Snapshot over-ride, the camera comes online. But after updating my items files, and sitemap, the stream comes up blank. I’ve tried to configure this cam using HIKVISION type, and even FOSCAM, and in both cases, again, the camera comes online, but blank streaming.

Cleared the cache, restarted OH. Don’t see any obvious errors in the logs, although I do not see any Get streaming URL’s in the logs like the other cams.

Any ideas??? Thanks for the help!!

You probably need to specify a URL for the streams. The other cams have the urls hard coded into the binding so it is not needed like other brands.

I just setup everything for my Ctronics IP Cam and I get this error:

2019-10-24 06:10:41.309 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Following NPE occured when trying to connect to the camera with ONVIF.java.lang.NullPointerException

2019-10-24 06:10:41.314 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Since an NPE occured when asking the camera about PTZ, the PTZ controls will not work. If the camera does not come online, give the camera the wrong ONVIF port number so it can bypass using ONVIF and still come online.

In my camera settings I have set the ONVIF to ON and the port is 8080
In the settings for the IPCamera I also set the port for ONVIF to 8080.

Why can’t it connect to it ? How can I solve this?

Yes, could not find a HTML stream for this guy. Returned the damn thing, and purchased a similarly priced Amcrest IP4M-1026W, and got it working in a few minutes. Camera web interface didn’t state the ONVIF port, but some trial and error it looks like it’s 8001. And for some reason, it would not connect properly as an Amcrest type, so I setup as DAHUA. But seems to be working well enough now.