IpCamera: New IP Camera Binding

Hey @matt1,
thanks a lot for your awesome binding. I works very well with my Foscam C1 & C1 Lite cameras.
I’m just missing one option: Turn on/off the Infrared Night LEDs. It is possible to implement such channel?
With the foscam cgi API it is already possible to control this state (foscam manual page 71)

Thank you!
It is working with url but the sliders is not working Ex: zoom

2018-08-11 15:03:34.075 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1__zoom' for widget org.eclipse.smarthome.model.sitemap.Slider

2018-08-11 15:03:34.081 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1__zoom' for widget org.eclipse.smarthome.model.sitemap.Slider

2018-08-11 15:03:34.085 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Slider

2018-08-11 15:03:34.091 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1_enableMotionAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.095 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1_enableMotionAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.099 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.105 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1__motionAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.109 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1__motionAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.113 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.119 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1_audioAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.123 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'ipcamera_ONVIF_739b35e1_audioAlarm' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.128 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch

2018-08-11 15:03:34.454 [ERROR] [ersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.

Looks like it is not yet in the API.
It is no where in the API documents PLUS it does not show up when using this URL which lists all the supported event triggers. Only what is listed at this URL is what the camera can do via the API.
http://192.168.1.6/ISAPI/Event/triggers

I also tried enabling it and then watching for it with this link, but it would not trigger
http://192.168.1.9/ISAPI/Event/notification/alertStream

You will need to email Hikvision and ask them if/when it will be in the API.

New Build 14-08-2018 changes are:

  • HIKVISION new alarm for PIR models. https://github.com/Skinah/IpCamera/issues/10
  • Foscam new ability to determin if the infraLED is turned on or off. @OzZy_HH I took a look at page 71 and the API only has the ability to OPEN and CLOSE the infrared filter, I believe this is not the same as turning the LED on and off. Can you test it please? Just enter the URL into any brower and watch what happens, if it does work then tell me the exact URL and I can add it to the same control I just added. Other brands do not have the ability to turn the LED on and off nor determine the state of the LED so this appears to be a foscam only feature.

Hi matt1,
thanks for the implementation. At the moment the “enableLED” channel reflects the current state of infrared LED lights.
I can change the sate with these requests:

root@raspberrypi:~# curl "http://foscam02:88/cgi-bin/CGIProxy.fcgi?cmd=closeInfraLed&usr=admin&pwd=xxx"
<CGI_Result>
    <result>0</result>
    <ctrlResult>0</ctrlResult>
</CGI_Result>
root@raspberrypi:~# curl "http://foscam02:88/cgi-bin/CGIProxy.fcgi?cmd=openInfraLed&usr=admin&pwd=xxx"
<CGI_Result>
    <result>0</result>
    <ctrlResult>0</ctrlResult>
</CGI_Result>

The foscam cloud app on my mobile also changes the infrared led state when I execute them.

There are two more options for infrared LED:
automatic and scheduled

root@raspberrypi:~# curl "http://foscam02:88/cgi-bin/CGIProxy.fcgi?cmd=getInfraLedConfig&usr=admin&pwd=xxx"
<CGI_Result>
    <result>0</result>
    <mode>1</mode>
</CGI_Result>
root@raspberrypi:~# curl "http://foscam02:88/cgi-bin/CGIProxy.fcgi?cmd=setInfraLedConfig&mode=0&usr=admin&pwd=xxx"
<CGI_Result>
    <result>0</result>
</CGI_Result>
root@raspberrypi:~# curl "http://foscam02:88/cgi-bin/CGIProxy.fcgi?cmd=getInfraLedConfig&usr=admin&pwd=xxx"
<CGI_Result>
    <result>0</result>
    <mode>0</mode>
</CGI_Result>

I am not sure whether and how these options should be implemented

Ozzy

New build 05-08-2018 new changes are:

  • Update Image settings now have a number in brackets in paperUI so you know the value of the option for textual config.
  • Foscam only: new abilities with infrared LED control

@OzZy_HH
I have taken a guess on how to best implement this and how it will work is only a guess as I dont have the camera to try and the names of the URL are not what I would choose. IE is closed off or on? Let me know if I got it back to front…

If you turn on or off the LED the auto control will move to the off position automatically. If you turn on the auto mode, then the other switch should move to indicate if the light is on or off.

Thanks a lot for the implementation. It works great and as expected. I can control the LED state with openhab, so I guess you used the correct commands (open=enable, close=disable). Also the “auto mode” control works well. The only thing I could complain is that it doesn’t get the updated/current state. So when I change automode by using the Foscam app it doesn’t change in Openhab. I’ve looked into the trace logs and couldn’t see the getInfraLedConfig request for pulling the current state.
Is this on purpose? (maybe to reduce the load?)

In general I’m already really happy with this binding :slight_smile:

Yes it was to reduce the load as Foscam at least some models can only answer four connections at once and I am not sure how that is counted. Have you tried using the openhab video element to display a high FPS video output in your sitemap? How does that work like in terms of displaying a picture in basic ui and the different openhab apps? Doing that I suspect counts as one of the four connections.

I’ve opened the stream in openhab and a second tab with the video grabbed the picuture with cmd=snapPicture2 command multiple times. During this peak time I still was able to send request by using curl. So I wasn’t able to reach a limit on my camera and couldn’t see any errors in trace log. Would it be possible to just pull once a minute (on low frequence)?

Hi Guys, once I setup the habpanel widgets for my webcam why the camera is showing over the widgets frame size. It won’t adjust to the widget frame size automatically. How can I change the resotion That will fit the camera image with on the frame size. I m running openhab on raspberry pi 3.

Thanks

@OzZy_HH
Open up the video stream in 5 different tabs of a browser, I have heard the 5th one will not work with foscam. Not sure which models and this limit may only apply to the video stream and the API connections may be unlimited. See if your camera can handle 4-5 video streams at the same time as the binding is polling it and let me know. Other brands also have limits, my amcrest has 10 connections with the ability to extend it to 20… Yes I have thought about putting into the frame work two different groups of URLs to poll. The approach I have been toying with is to have a list that may be 10 URLs long and each time the camera polls the alarms it will choose 1 from the low priority list to poll.

Hi there,
I have the same IP Camera from Ahmed. I use this code in Sitemap, but I have to authenticate all time, as soon as I authenticate is working pretty fine, but I wouldn’t like to authenticate everytime.

Webview url="http://192.168.0.104/web/mobile.html" height=16

It is not possible to disable the authentication or at least pass the log in through the address???

With “http://user:passw@192.168.0.104/web/mobile.html” is not working for this camera. So, this mean that I have to use IMAGE and refresh, instead of VIDEO?

Thank you.

Hi

With webview you’ll need to authenticate each time to see camera output from mobile.html feed which is refreshed picture, not video stream.
To achieve that you need Image item: Image url="http://admin:admin@192.168.8.101/tmpfs/auto.jpg?" refresh=1000

This camera gives you rtsp feed as video, but it’s not very stright forward how to get Video working especially using mobile Openhab app.

i.e rtsp://192.168.1.100/11 gives you channel 11 rstp data. Works with vlc.

This camera(at least mine) does not have any controls like move or zoom even there are buttons available.

Regards

Well, I do get video streaming from “mobile.html” in Sitemap, but I have to authenticate everytime, that is my problem. This is the point. But of course you can get live streaming through mobile.html in Sitemap. It works. The problem is that admin:admin does not work in the URL “/…/mobile.html”

I have tried that, but if you use “auto.jpg”, you do not need authentication “admin:admin”, at least I do not need it. It is working fine without authentication but only “auto.jpg”…

That url format will only work if the camera supports BASIC auth, not for cameras that use DIGEST auth. Out of interest what happens if you use this binding as a HTTPONLY thing and supply the address for the snapshot as this…

http://192.168.8.101/tmpfs/auto.jpg

Leave off the login details and see what the binding reports in the logs in TRACE. The binding will tell you if it is using digest or basic auth for your camera as well as what the camera is sending back.

I understand you are trying to get the video or webview working, but you may learn something about the camera by trying that.

But that url was written by ArC not by me, I only quoted what he/she said.

I made some test yesterday, but I did not have a look on the log sorry, I have just see now your answer. This evening I will repeat it but:

I did not have a look on LOG. I will do this evening. But I do not see anything clear.

Is there other way to auto login?
Is this happening because my way of auth is DIGEST and I do not use it properly?

Thank you!

EDIT:

I have checked via SSH the logs, and the only warning I have is this (on openhab.log)…

2018-08-16 21:47:07.533 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: java.net.NoRouteToHostException: No route to host

on events.log there is no ERRORs reported.

Hi @matt1 I want to create static .things file for my Foscams. Is there any guide for this already?

@zacofunny
Yes on Github there are full things, items and sitemap examples with explanations on what to do, about half way down the page.
https://github.com/Skinah/IpCamera/blob/master/README.md
The only thing not covered there is the special URL for motion detection arming which you can search this thread for where it was discussed. Also if you drop the refresh rate too low or have multiple cameras you may get OOME which this thread has a fix listed in it for that as well. Two things for me to consolodate back into the readme. Any questions not covered in the readme just ask and I will update it.

@grhosso
Your errors are not from this binding. The openhab methods to my knowledge do not support DIGEST, If your camera uses DIGEST I suspect this binding is your only option to get a picture as that is exactly what the binding does for you, it auto enters the log in details for every transaction you make so you do not have to.

1 Like

Understood. I guess my camera use DIGEST. I will clarify with the Seller maybe they can tell me if is used DIGEST and afterthat I will implement something. I will keep on testing.

just to clarify, which BINDING you mean?? or you mean “Image Item” ?

Thank you for the help.

Please read post number 1 of this thread you are in right now, or the link to the readme in my last post :slight_smile: