IpCamera: New IP Camera Binding

There is a problem then and my first guess is that you have not turned on the CGI/API in the cameras setup. Hikvision cameras come with the API disabled and no ONVIF user/pass setup so both of these are needed to be done. See the documentations steps on how to setup Hikvision.

There is an update in the latestest snapshot, can you update to it and retest? The sharable thing is new to me and if it is still occuring, then I will have to look into to see if it can be reproduced here… You dont need to scan and find cameras, manually adding them is more than fine and wont be causing the info log problem.

@matt1 thank you for this incredible binding. I have just started working on it. I can confirm it works with the Wainsview line of cameras using ONVIF.

I have done some reading on motion and object detection and must admit I am confused about where to begin. The Wainsview cameras do not seem to have very good detection (or it detects everything that moves).

I would like to be able to detect people, faces if possible, car and license plates if possible. Does the binding do that or do I need a third party application and something like google coral?

I don’t know much on object detection yet, but it would be an idea to weigh up the cost of a camera that has it built in. The CPU load to process multiple cameras means that you are best looking at coral or a GPU to offload the processing otherwise your looking at 1 FPS rates at detecting the objects which is OK for sensing objects to use in rules, but if your also wanting to see realtime boxes around the objects you may want a higher rate which the coral is good for. Then there is the issue of network traffic, your best to run multiple cameras and a 3rd party app on a separate switch to keep this traffic away from your openHAB server. For a low number of cameras that is less important to do.

If you want to get started, then there are these ways which I have not tried.

1 Like

Updating to this version and forcing the transport to UDP worked to successfully generate images from the rtsp stream. Thanks for making this binding.
Should the selection of transport al be part of the UI options? (I personally don’t have a big problem with adding the argument manually (-rtsp_transport udp))

@matt1 hi Matt,

have you come across a case when adding cameras that it causes issues with other bindings?
I have this case where i have added something like 20 cameras via the RTSP protocol (Hikvision didnt work). they appear on the clickcamera widget. but after finishing and runnign a reboot, the zwave binding has gone offline (and it wont come back online)

almost as if i used up too many system resources - does this make sense?
would it be the habpanel json or the number of rtsp cameras you think that causes it?

(i should add that if i reflash the sd card to prior to adding cameras it is back to normal)
If I remove the ipcamera binding - reboot - it is back to normal. then if I add the binding everything is ok (i guess until next reboot)

Alex

Yes there is a whole thread on this. Milestone 3 fixes this for most people but the latest jar and milestone 4 (due out in 1-2 weeks) should have it resolved.

@alexkarageorgis
This post should have all the info in it that you need.

IpCamera binding - Breaking changes and new features in 3.2 Milestone 3 and newer - Add-ons / Bindings - openHAB Community

1 Like

@JimT, I made rules for my Dahua and Hikvision cameras to change the switch times based on the Astro binding. Let me know if you’d like to see how I did it.

I’d love to see your code. I just use Sun elevation (also from astro). I’d like to also do it based on light level, e.g. when it’s very overcast / raining during the day, switch it to night profile too. I haven’t figured out how to determine the light level. I’d like to do it based on the camera / camera feed itself, and not have to use extra external lux sensors.

Here’s my current code, written in JRuby OpenHAB Rules System

require 'openhab'
require 'net/http'
require 'net/http/digest_auth'

SUN_ELEVATION_THRESHOLD = 5 # Threshold for switching camera profile to day/night

def http_digest_get(url, user:, pass:)
  digest_auth = Net::HTTP::DigestAuth.new

  uri = URI(url)
  uri.user = CGI.escape(user)
  uri.password = CGI.escape(pass)

  h = Net::HTTP.new uri.host, uri.port

  req = Net::HTTP::Get.new uri.request_uri

  res = h.request req
  # res is a 401 response with a WWW-Authenticate header
  auth = digest_auth.auth_header uri, res['www-authenticate'], 'GET'

  # create a new request with the Authorization header
  req = Net::HTTP::Get.new uri.request_uri
  req.add_field 'Authorization', auth

  # re-issue request with Authorization
  h.request req
end

def dahua_set_profile(ip, profile, user, pass)
  profile = { day: '0', night: '1' }[profile]
  http_digest_get("http://#{ip}/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=#{profile}",
                  user: user, pass: pass)
end

rule 'Dahua: Profile switch to day' do
  changed Sun_Elevation
  on_start
  run do |event|
    if Sun_Elevation > SUN_ELEVATION_THRESHOLD && (event.nil? || event.was <= SUN_ELEVATION_THRESHOLD)
      profile = :day
    elsif Sun_Elevation < SUN_ELEVATION_THRESHOLD && (event.nil? || event.was >= SUN_ELEVATION_THRESHOLD)
      profile = :night
    else
      next
    end
    logger.info("DAHUA PROFILE switched to: #{profile}")
    dahua_set_profile(CAMERA_IP['Street'], profile, CAM_USER, CAM_PASS)
  end
end

Thanks Matt,

I am going to have a look at Frigate

hi matt1, I am on milestone3 actually already.
For now I am ok after the unistall/re-install of the binding. Reading up on the link TY and waiting on m4.

the only thing which is strange (besides +10C temp on the RPI) is that the HLS stream isn’t consistent on my Amazon Firehd tables/Habpanel. It is better on my mobile phone (samsung note10).

so I have this

but some streams work better/appear and some just stay blank like below. (same setup ofcourse and all from the same NVR)

Is there some way to make the HLS stream faster to load?
Snapshots work ok every 5 seconds (question 2 - do snapshots keep getting “taken” even when the clickable widget isnt the active window?)

This is covered in the documentation here
IP Camera - Bindings | openHAB

With 20 cameras yes I am not surprised that M3 is still an issue, I have not tested that many before but you do not need to wait for M4 as I have uploaded the jar if you wish to try it out.

That is difficult to answer as it depends on the browser and the widget. You can easily check yourself by using DEBUG log output. Sometimes it is needed to press refresh on a browser after you leave the page to stop some streams.

Your streams not starting whilst others do, are any of them hikvision with digest? if so see here…

IpCamera binding - Breaking changes and new features in 3.2 Milestone 3 and newer - Add-ons / Bindings - openHAB Community

@matt1 I read that part - but I assumed that given I am talking to all cams through an NVR - same ip of NVR for all 20 cams/RTSP/different channels it isnt relevant to me? Should either work or not.

will try the new jar and revert after I read the debug info also.
thanks

Newer jar just uploaded for the hik digest bug. I have fixed a lot of bugs since M3 so you may find it now works with the newer jar. A NVR can be setup to allow each camera to be accessed via its own port, in that case it would depend on the cameras settings.

my NVR is a hybrid one - some analogue and some ip cameras. - it doesnt offer the option of port specific access. this is why i access via rtsp / channel by channel :slight_smile:

@matt1 uploaded the jar from here - http://www.pcmus.com/openhab/IpCameraBinding/
added it into the folder - usr/share/openhab/addons.
rebooted the rpi for good measure.

how do i know if it updated? does the below make sense? (it says the old Bundle is waiting)

Just updated and enabled CGI on the cameras. Everything seem ok now. No more repeating INFO messages.

Still can’t SCAN though, but adding manually works fine.

Thanks.

I use curl within Rules.

val logName = "Update Camera Schedule"
  
    val String DawnHour = astro_NauticDawnEnd_dt.state.format("%1$tH")  //%1$td.%1$tm.%1$ty %1$tH:%1$tM"
    val String DawnMinute = astro_NauticDawnEnd_dt.state.format("%1$tM")  
    val String DuskHour = astro_NauticDuskStart_dt.state.format("%1$tH")  
    val String DuskMinute = astro_NauticDuskStart_dt.state.format("%1$tM")  

    logInfo(logName, "Updating Camera Schedules: " + DawnHour + ":" + DawnMinute + " " + DuskHour + ":" + DuskMinute)

    //Amcrest
    // curl --anyauth --globoff -u username:yourpassowrd "http://10.1.1.201/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseHour=23"
    
    val strA = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseHour=" + DawnHour
    createTimer(now.plusSeconds(1), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strA) ])
  
    val strB = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunriseMinute=" + DawnMinute
    createTimer(now.plusSeconds(2), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strB) ])

    val strC = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunsetHour=" + DuskHour
    createTimer(now.plusSeconds(3), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strC) ])

    val strD = "http://10.1.1.208/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SunsetMinute=" + DuskMinute
    createTimer(now.plusSeconds(4), [| executeCommandLine("curl", "--anyauth", "--globoff", "-u", "username:yourpassowrd", strD) ])

Thanks @msexton187! This is much better than relying on openhab to perform the actual switching. I wasn’t aware of the sunrise / sunset hours being available. Indeed I could just set the time from astro and even add/subtract as I see fit.

@JimT and @msexton187
I created a github feature request here so if you want to do some testing and give feedback, it can be captured in one place to be looked at getting added.

[ipcamera] Day/Night profile switching features · Issue #11470 · openhab/openhab-addons (github.com)

Hi,

first of all, thank you for developing this binding.

I’m testing out a low budget camera Reolink RLC-410W. Some things work, some things don’t. But one step at a time.

First issue I’m trying to solve is HLS Stream. curling /ipcamera.m3u8 gives empty reply. The logs say:

2021-10-30 15:42:21.700 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://admin:********@192.168.0.77:554/h264Preview_01_main -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4 /var/lib/openhab/ipcamera/1ae736639a/ipcamera.m3u8
2021-10-30 15:42:22.591 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Invalid loglevel "warning". Possible levels are numbers or:
2021-10-30 15:42:22.594 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "q�iet"
2021-10-30 15:42:22.609 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "panic"
2021-10-30 15:42:22.613 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "&atal"
2021-10-30 15:42:22.617 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "error"
2021-10-30 15:42:22.620 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "warning?verbose"
2021-10-30 15:42:22.624 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "info"
2021-10-30 15:42:22.626 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "verbose"
2021-10-30 15:42:22.630 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "debug"
2021-10-30 15:42:22.640 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - "trace"

So ffmpeg complains about wrong loglevel settings. This is my ffmpeg version: “ffmpeg version 4.1.8-0+deb10u1+rpt1”. Is this a known problem? Binding version is 3.1.0