IpCamera: New IP Camera Binding

It should already be working, does it not work for you? If not put the logs into TRACE (how to do this is in the readme) and supply what the camera is sending the binding when the alarm is triggered. Since I am trying to keep/reuse channels so the naming is consistent it is probably called line crossing not tripwire. Take a look at the available channels in PaperUI and you will see a lot of features that have been added for Dahua cameras.

I have seen weird things happen if you don’t clean the cache and tmp folders out with Openhab and it is one of the top 2 things that annoys me about Openhab. Whenever you change something this should be the first thing you try.

Ok and howto clean the cache?

In Linux the following should work, for other platforms search this forum…

sudo service openhab2 stop && sudo rm -rf /var/lib/openhab2/cache/* && sudo rm -rf /var/lib/openhab2/tmp/* && sudo reboot

Hi @matt1,

thank you very much for the great binding you created!
It took me while to get it going, since it also requires to get the matching settings going on the camera side. But nevertheless, I am learning a lot and it is fun.
Here are a few questions:

  • Is there any way to get the current pan/tilt/zoom information from the camera?
  • My camera can be programmed with several PTZ positions; How can I select those using your binding?

Cheers…

Ok cache cleared and rebooted. Let’s see what it brings…

@sl92656
Glad you like the binding and find it useful. If you have any feedback on what you found a hurdle to get it going please do so as I use it to update the readme and the binding and feedback from new comers is valuable as often when you program the binding you overlook how someone else thinks or expects something to work…

Great to hear as most people here don’t mind giving people help if they put the effort in to learn instead of wanting to be spoon fed.

Yes it is implemented but sadly not all cameras are truly ONVIF as there is no requirement to have a camera independently tested before it can advertise onvif compliance, often they passed a onvif 1.1 test and hence they put a label on the product when we are now at > 2.4 onvif version.
My Amcrest camera will report its position, but note that the binding only does this when the camera is connected for the first time, if you move the camera in a 3rd party app and want Openhab to reflect the change then this would need to be a feature request.

There is an example of how I do it in the readme file for my baby monitor. I use openhab to create the presets as this will be cleaner and more consistent between camera brands and also it allows you to learn the concept of SCENES which can be used for lighting in your home. It also means you don’t need to setup things in the camera and your backups contain a better snapshot of how your setup truly is. Do some searches in the solution forum for scenes and you will find posts like this one that will explain how to tackle things in new ways you may not have thought about…

@matt1,

thanks for the quick response!

Consider this a feature request. Here is my reasoning:
I use the camera’s motion detection feature to create an alarm. To setup the motion detection zone, I do have to use the camera app (i.e. in my case “Amcrest Web View” on an iMAC for my Amcrest IP4M-1051) to define the zone. In order to match the Pan/Tilt/Zoom values in Openhab, I move the sliders to somehow match the position, which is a trial/error activity. It would therefore greatly be simplified if the binding would provide channels that show the currently active position, at which point I can copy those values over to OpenHAB. If those values are not updated on a regular basis, the process gets quite tedious.

I forgot you can already do that with the REFRESH command, you will need to poll the camera which is why it is not the default behaviour…

example…

items:

Dimmer CamPan "Pan [%d] left/right" { channel="ipcamera:DAHUA:001:pan" }
Dimmer CamTilt "Tilt [%d] up/down" { channel="ipcamera:DAHUA:001:tilt" }
Dimmer CamZoom "Zoom [%d] in/out" { channel="ipcamera:DAHUA:001:zoom" }

rule:

rule "refresh"
when
    Time cron "0 */2 * * * ? *"
then
    //your ITEMS to refresh every 2 minutes here
    CamPan.sendCommand(RefreshType.REFRESH)
    CamTilt.sendCommand(RefreshType.REFRESH)
    CamZoom.sendCommand(RefreshType.REFRESH)
end

Hi Matt

Have you had a chance to implement this yet?

No, while it is a <5 minute job to add the feature, the recent changes made to the build system mean I can not create any more builds until the binding is converted to the new bundle format and finding 4+ hours to sit down and do that is a challenge. Next rainy day…

Hi @matt1,

thanks for the pointer. One thing to mention, in order for the REFRESH command to work I had to add

import org.eclipse.smarthome.core.types.RefreshType

to the top of the rule file.

I then got the info from your binding, BUT, it seems that the values reported did not come from the camera. Here is my log; after several movements of the camera (from outside of openHAB):

2019-05-16 21:39:10.020 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Pan is updating to:78 and the cam value is 0.55999994
2019-05-16 21:39:10.079 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Tilt is updating to:80 and the cam value is 0.5999999
2019-05-16 21:39:10.098 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Zoom is updating to:1 and the cam value is 0.007812
2019-05-16 21:39:15.015 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Pan is updating to:78 and the cam value is 0.55999994
2019-05-16 21:39:15.036 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Tilt is updating to:80 and the cam value is 0.5999999
2019-05-16 21:39:15.045 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Zoom is updating to:1 and the cam value is 0.007812

None of the values changed. Is the binding requesting the PTZ position from the camera when the REFRESH command is sent or is the binding just reporting back the item value without polling the camera?

Your correct, I just went and checked the code and it is missing a single line to update the current position when asked to refresh so it is not something you are doing wrong. 99% of the coding is done and is simple to get this going and it looks like your camera is compatible, BUT see my previous reply to Dave…

ptzLocation = getPtzPosition();

@matt1, thanks for quick reply!
No sweat, any time you tinker with the code again, keep this in mind (hope rain is in your local forecast :wink: )

New build 2019-05-23 is now available with these changes:

  • Uses new bnd bundle build system to work in future releases of Openhab. I am using it under 2.4 stable for around 4 days now with no issues.
  • Can disable the ipwhitelist if you make it equal DISABLE in all caps. @delid4ve requested this ability.
  • The PTZ can now fetch updated locations, but only if you request the PAN is updated first. @sl92656 requested this feature.
  • Bug fixes for httponly thing types as they had some issues using the new stream features in all previous builds.

There are now a number of extra Jar files that you MUST drop into the addons folder for the binding to work, they are all in the zip file together.

Also when upgrading you MUST clean the cache and tmp folders as the binding is now built differently and no old cache can remain or you will get issues…

Under linux this can be done with this command:


sudo service openhab2 stop && sudo rm -rf /var/lib/openhab2/cache/* && sudo rm -rf /var/lib/openhab2/tmp/* && sudo reboot
1 Like

@matt1, this is great news! Thank you very much for spending all the time to implement all these changes. I wished I could help, but the programming at that level is above my grade. I tend to stick to embedded systems…
BTW, with your motion GIF feature I learned that we have a frequent visitor at our house, see here:
ipcamera1
ipcamera2
It’s good a long weekend is coming and I can “Labor for a Day” to check out the new features…

1 Like

No problems, glad you enjoy the binding. Great to see some examples of the animated GIF feature. Do you happen to have a chromecast as I am keen to hear from anyone that uses the HLS feature to cast the camera.

Feedback is always a big help as all cameras handle things differently and I can not own lots of cameras. For example with your gifs above, where is the cat when the trigger that starts the creation occurs? Do you have a tripwire alarm setup at the steps or is it a normal motion alarm and the camera takes some time to provide the feed from where the cat triggers the alarm?

For reasons why I am interested, see this thread…

@matt1,

I tried your new version, but did not succeed. No IP camera access possible anymore.
My camera model is: Amcrest IP4M-1051
I am running on a Rpi 3.
My openhab version is:

###############################################################################
################# openHABianPi #################################### 7.05.170509 
###############################################################################
##        Ip = 192.168.1.200
##   Release = Raspbian GNU/Linux 8 (jessie)
##    Kernel = Linux 4.9.35-v7+
##  Platform = Raspberry Pi 3 Model B Rev 1.2
##    Uptime = 5 day(s). 2:36:10
## CPU Usage = 2.06 % avg over 4 cpu(s)  (4 core(s) x 1 socket(s))
##  CPU Load = 1m: 0.17, 5m: 0.41, 15m: 0.58
##    Memory = Free: 0.08GB (9%), Used: 0.85GB (91%), Total: 0.94GB
##      Swap = Free: 0.09GB (95%), Used: 0.00GB (5%), Total: 0.09GB
##      Root = Free: 101.93GB (96%), Used: 3.64GB (4%), Total: 110.07GB
##   Updates = 121 apt-get updates available.
##  Sessions = 1 sessions
## Processes = 138 running processes of 32768 maximum processes
###############################################################################

              Welcome to            __  _____    ____  _
            ____  ____  ___  ____  / / / /   |  / __ )(_)___ _____
           / __ \/ __ \/ _ \/ __ \/ /_/ / /| | / __  / / __ `/ __ \
          / /_/ / /_/ /  __/ / / / __  / ___ |/ /_/ / / /_/ / / / /
          \____/ .___/\___/_/ /_/_/ /_/_/  |_/_____/_/\__,_/_/ /_/
              /_/
                  openHAB 2.3.0-1 (Release Build)

Here is the filtered log:

2019-05-25 19:17:28.924 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:17:52.750 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.items'
2019-05-25 21:20:06.499 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'ipcam.rules', using it anyway:
2019-05-25 21:20:06.516 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.rules'
2019-05-25 21:20:51.921 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2019-05-25 21:21:16.787 [ERROR] [org.openhab.binding.ipcamera                      ] - FrameworkEvent ERROR - org.openhab.binding.ipcamera
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:21:39.114 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 19:17:28.924 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:17:52.750 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.items'
2019-05-25 21:20:06.499 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'ipcam.rules', using it anyway:
2019-05-25 21:20:06.516 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.rules'
2019-05-25 21:20:51.921 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2019-05-25 21:21:16.787 [ERROR] [org.openhab.binding.ipcamera                      ] - FrameworkEvent ERROR - org.openhab.binding.ipcamera
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:21:39.114 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 19:17:28.924 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:17:52.750 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.items'
2019-05-25 21:20:06.499 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'ipcam.rules', using it anyway:
2019-05-25 21:20:06.516 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.rules'
2019-05-25 21:20:51.921 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2019-05-25 21:21:16.787 [ERROR] [org.openhab.binding.ipcamera                      ] - FrameworkEvent ERROR - org.openhab.binding.ipcamera
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:21:39.114 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 19:17:28.924 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:17:52.750 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.items'
2019-05-25 21:20:06.499 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'ipcam.rules', using it anyway:
2019-05-25 21:20:06.516 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcam.rules'
2019-05-25 21:20:51.921 [INFO ] [.smarthome.model.core.internal.ModelRepositoryImpl] - Loading model 'ipcamera.things'
2019-05-25 21:21:16.787 [ERROR] [org.openhab.binding.ipcamera                      ] - FrameworkEvent ERROR - org.openhab.binding.ipcamera
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]
2019-05-25 21:21:39.114 [WARN ] [org.apache.felix.fileinstall                      ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [197]

Could it be, the problem is me running openHAB 2.3? I am not ready to move to 2.4 or 2.5 because of all the MQTT changes that I read about…
Hope this helps.

Good morning all.
Has anyone configured a TTGO -TCamera ESP32 with the binding?

I ordered some a while ago to play/learn with before purchasing a real camera.
Future will be outdoor cams for front and back of my house, however I am experimenting with setting one of the ESP32 cams up as an indoor monitor, more or less as a baby cam (lol!) for my 5 year old ‘still a puppy’ Boxer.

I have flashed the following on one of the modules, but have not had much success with the binding configs as I have very little experience with cameras having never owned one before.

I have added the 2019-05-23 IpCamera binding, and am attempting to set a TTGO-T Camera module up as a generic HTTP camera. Success when adding it as a thing, but i them become stumped with other settings, including for the RTSP section.
I’ve been reading and attempting to set one up as much as I can before asking for help, but am now at that point where I’m not certain if I’m doing something incorrect or this will actually work as I have not had any success.

openHAB 2.5 Snapshot#1555, as Debian VM running under ESXI 6.7 with more than enough RAM and a Xeon processor, and ffmpeg is installed.

Any help is appreciated, I just need that starting point boost!

Note: From the linked page for the firmware for the ESP32 module I was not able to get the RTSP stream to work with VLC (Windows 10 machine which I rarely use due to a random reboot ‘feature’ that I can’t track down and resolve…) so maybe a firmware issue?
Note2: tried the rtsp feed with VLC on ChromeOS (android app) and success! so should be fine.

Thanks in advance for your help,
Craig

Edit: Fix typos, add openHAB version, note on VLC streaming

It is possible as I do not know how far back the binding will work now that it is using the newer bundle format. If you cleaned out the cache and tmp, then I would suspect it is your version. I have it working on 2.4 Stable… I would recommend you do upgrade when you get a chance as the mqtt issue is easily solved and my guess is that the next 2.5 will take ages to get it as stable and bug free as the current builds. Hopefully I am wrong about it, but too much has been changed for it not to ripple bugs and regressions.

No and I am not too keen on getting one as I have heard that they overheat if you stream non stop for any length of time plus they lack nightvision. For taking a quick look at your dog and not leaving the stream open I guess it could be a great value way to get a cheap camera.

Great, can you post the rtsp link that worked in VLC as that seems to be missing from every guide I have read. What would be ideal if the camera can provide a snapshot, mjpeg and also a h264 stream all at the same time. My guess is the heat will be an issue if trying to tax it that much so it will probably be limited to a single stream. Please let us know what you find.

I cleared cache and temp and also rebooted the Pi, to no avail.
I will have to switch back to your previous version until I make the jump to 2.4, thanks!