[APP][Pro] Support for ONVIF compatible cameras (Release 2.0.41)

I have created an app that supports ONVIF compatible video cameras. The cameras must support the following requirements:

  • S and T profiles of the ONVIF specification,
  • Provide a snapshot URL to obtain a JPEG snapshot,
  • Support Pull points for motion capabilities. (version 0.0.22 adds WS_BasicEvents, also known as Push points, but is not fully tested).

The main differences between this app and the Homey IP camera support are discovery and motion detection.

There are two snapshot views for each camera, the ‘live’ image and one at the point that the last motion was detected (or delayed by a user specified amount after the motion detection). Motion will also generate a trigger for flows and both snapshots are available as tags to be used with other action cards. That allows you to send the image to your phone, etc.

I will attempt to publish it so just need to see if Athom will allow it.

The app is now live. The release version is here:

Sometimes there may be a test version available here:

Not all cameras support motion detection via ONVIF, even if they have motion detection capabilities. Sometimes this is because the manufacture does the motion detection offline rather than in the actual camera. Other times it is just because they have not implemented the Pull Points part of the specification.

Cameras known to be test so far:

  • H.View HV-E800
  • Unbranded HI3516EV200
  • FOSCAM FI9900EP V5 (does not support motion detection via ONVIF)
  • DBPOWER hd Cam: Chinese cheap outdoor cam full HD, already included in Homey, immediately recognise and working with your app, I did not test the motion alarm yet
  • IMOU IPCG22: new full HD outdoor cam, already included in Homey, IP recognise but it returns the following error - Cannot read property ‘width’ of undefined
  • EBITCAM F220: outdoor full HD cam, IP not recognised - I’m sure this cam needs a token to grab a snapshot so it may be not usable with your app
  • Dahua DH-SD22204t-GN-W and Dahua HDBW1320E are working with version 0.0.22.
  • Neo CoolCam NIP-55 working
  • HiKam S6 does not have a still image URL so not possible to show either image in Homey.
  • Chinese unbranded DG-MYQ, motion works but no image URL.
  • Eminent EM6330 cameras are working but No ONVIF motion detection.
  • Milesight 360 panoramatic
  • Imou Ranger iq (IPC‑A26HIP) fully working
  • Imou Looc (IPC-C26E) fully working
  • Imou New Bullet (IPC-G26E) fully working
  • Reolink RLC-410W fully working
  • Reolink RLC-520 fully working
  • HikVision DS-2CD2183G0-I
  • Imou bullet lite, not detected.
  • Imou cue 2, no snapshot or motion.
  • TP-Link C100, no snapshot.
  • IMOU Cube 4MP (IPC-K42P) Works in Homey.

If you have experience with other cameras that either fully work, partially work, or don’t work please reply to this topic with the details and I will update the list.

**To add a camera, ** use the standard add device method of Homey.
During the process, the app should discover all the ONVIF cameras on you LAN and present the list to you. This can take about 15 seconds so please be patient.
Version 1.1.18 and later add an entry on the end which is an option to manually add a camera by specifying the IP and port required to connect.
Once the list is displayed you can select one camera to add and then tap Next. You will see the screen to enter the camera login credentials (note some cameras have different credentials for ONVIF and standard access). If you chose the manual entry, then you also enter the IP and port number. Once you have entered the details, select Next. The app will try to login to the camera to verify the credentials and if all goes well the camera will be added.

If the ‘Camera’ is actually an NVR that supports multiple cameras by channel number, you will see an extra list of cameras connected to the NVR. You can then select which of these cameras are added to Homey.

If you have any issues, then the app has a Diagnostics Log feature that can be switched on in the Apps - Configure app section:

Switch the logging on by ticking the LOG ENABLED option. The setting is remembered through app restarts so it can be used to log the complete start up process.
The log is limited to 30kB at which point it will remove the first 5kB to make space for more information.
Note: Logging will add extra load to Homey so it is recommended not to keep it switched on all the time.
You can clear the log if required by taping on Clear Log and you can send the log to me by taping on Send Log. You will see a confirmation message before sending the log. Only the information in the log window is sent and there is no identifiable information included so if you are reporting a problem then please contact me either on here, via a PM or on GitHub to follow up on the problem.

The app looks like this:

  • Image from the last motion event (drop list set to MOTION EVENT)

  • Image from last snapshot (drop list set to SNAPSHOT).
    This can be refreshed at any time by pressing the round arrows below the image.

  • It is possible to enable / disable the motion detection here (the image shows motion detection switched off): When the motion is switched off, the trigger will not activate, and the image will not update unless you use a flow card action.

  • You can view the current state of the alarms, etc:

    The OFFLINE alarm is triggered if the app has recently lost communication with the camera. It can take up to 30 seconds to detect. After about 1 to 2 minutes the app shows ‘Not Available’.
    This could mean the camera has been disconnected or the IP address has changed. If the IP address has changed you can use the Repair option to redetect the camera or change it manually in the advanced settings (see below).

  • The CAMERA TIME is the time reported by the camera. However, the Event times are taken from Homey.

  • Taping on the cog (top right of the images) takes you to the settings screen:

    Here are the standard Name and Zone settings plus you can open the Advanced settings:

  • The Username and Password are the credentials required to log into the camera via ONVIF. Check your camera settings to make sure this has been setup.

  • Camera Enabled: You can temporarily disable a camera if required. This will halt the online / tamper checks, etc. If you are going to disconnected a camera for any length of time then it will save some processing time if you disable it. Also if you have a problem camera that you want to capture logs for, disabling all the other cameras can reduce the amount of ‘noise’ in the logs and make it easier to debug.

  • Device Class: If the class is set to Sensor then you will see the red triangle in the tile when motion is detected. If you set it to Camera then it is possible to configure some dashboards to show the camera image on the main display.

  • Single: when set, this option determines if just one snapshot per new trigger is captured, e.g., the trigger must be cleared by the camera before another image is captured. if it is not set then an image is captured each time a new motion event is triggered even if the last one is still active.

  • Delay: this is the time before the image is captured after the trigger is enabled. Some cameras are overly sensitive and will trigger before the person has fully entered the image, in which case you might only get the edge of them.

  • Channel: If the IP is an NVR that supports multiple cameras on channels, this field shows the channel number of the camera and can be changed. Set to -1 to prevent the channel number being changed if it is not an NVR.

  • Token: If the IP is for an NVR that supports multiple cameras on channels, the event notification will include a Token to identify which camera has sent the notification. This should be filled in during the pairing process, but can be changed or set if required.

  • Prefer Pull Events: When a camera supports both Pull and Push events, the app will use Push events by default. Switch this option is on to override that and force the app to use Pull events. Push events are more efficient then Pull events but there may be times that they won’t work, such as on different VLANS.

  • Time format: allows you to choose from a few options for the time and date shown on the alarms view. The default is Short HH:MM DD-MM which is a format that fits the space provided by the view on most phones.

  • The last section mainly shows information about the camera provided during pairing, but there are a few options that can be changed:

  • USER Snapshot URL: If you enter a URL in this field, it will override the one returned by the camera.

  • ONVIF Motion Notification to use: Some cameras support multiple notification events. They are listed in the field above this entry. Even though a particular type is supported, it might not be enabled in the camera, plus some types are more reliable than others. If you are not getting notified for motion then try selecting a different option here. If you are getting false notifications, e.g. events when the light changes or a bush moves in the wind, then try selecting a different option.

  • Event Object ID: For cameras that support regions of face recognition, etc, they might send an Object ID to identify the region or face. If this field is empty then any ID will generate an event. If an ID is specified then it must match the ID sent in the event notification. You can specify multiple ID’s by separating them with a comma, in which case an event will be generated if any one of the specified ID’s is received.

  • The Maintenance screen has an option to set the cameras time to the same as Homey and an option to run the repair routine:

Motion image is ready within… flow condition
This Condition card can be added to the AND section of the flows. It allows you to wait for the image to be capture before running the Action cards.

So, to use it you would first trigger the motion capture with the relevant Action card in a flow. This might be in response to an external motion sensor for example. Then in another flow that is triggered by, say, the doorbell button press for example, you would add this card to the And section to make sure the image is ready to send to your phone, etc by the Action cards.

**Change log: **

Version 0.0.2

  • First beta release.

Version 0.0.6

  • Complete re-write of the discovery process as some cameras required authentication to obtain some of the basic information.
  • Added a log page to the Configure app button in the Apps - ONVIF section of Homey. This provides debug information to help solve any issues with specific cameras.
  • Extra error traps to reduce crashes.

Version 0.0.10

  • Improves reconnecting to a camera that has been offline,
  • Added Repair feature to reconnect a camera when the IP address or login details have changed,
  • Added a button to the Log screen to send the log to me.

Version 0.0.20 / 0.0.21

  • Added Digest Authorization with auto detection when none, Basic, Digest headers are required.

Version 0.0.22:

  • Partial implementation of ONVIF Basic WS_Notifications (push events).
  • New flow trigger card for ‘Motion Image Ready.

Version 0.0.36:

  • Updated push event method
  • Added motion alarm to device tile.
  • Added option to switch between push and pull events when both are available.
  • Tidy up of switching events on and off.
  • Added retries to event image capture.
  • Implemented Push Events Refresh instead of unsubscribing and subscribing.
  • Now detects IsTamper event and set the ‘Offline / Tamper alarm’.
  • Optimised network timeout for pull events.
  • Re-enable events when camera comes back online.
  • Made device class settable between camera and sensor in Advanced Settings.
  • Optimized libraries to reduce the size of the app.
  • Extra diagnostics and fix for invalid video source object
  • Extra diagnostics for connect camera function
  • Added German, Dutch, and Italian.
  • Try getSystemDateAndTime with credentials if it fails without.
  • Moved camera offline check to the app to smooth out processor demand when lots of cameras are added.
  • Filter out devices that are not proper ONVIF cameras from search
  • Fixed case where the password was appearing in the log.
  • Fixed issue with Sync Time function.
  • A bad snapshot URI is rechecked during the camera check.

Version 0.1.1

  • Fix crash when Sync. Time fails
  • Send log change for better reliability
  • Added a few more checks for bad data from cameras.
  • Changed order of images so the ‘Now’ image is the default when the section is selected.
  • Added “Motion image is ready within…” flow condition
  • Deprecated “Update Now snapshot” flow action
  • Added “Update Motion snapshot” flow action.
  • Motion image available even when camera does not support it so that the flow trigger can update it.

Version 1.1.2

  • More logging

Version 1.1.3

  • Handle missing time from camera.

Version 1.1.4

  • Put catch around each image retrieval method instead of relying on camera returning a failure message.

Version 1.1.5

  • Switches log off when full instead of clearing it.

Version 1.1.6

  • Added diagnostics to find a specific problem

Version 1.1.7

  • More logging

Version 1.1.8

  • Fix IP address returned from pull point subscription on some cameras

Version 1.1.9

  • Allow channel to stay set to 0

Version 1.1.10

  • Extra error logging

Version 1.1.11

  • Fixed enable / disable flow actions. Improved robustness against network failures.

Version 1.1.12

  • More diagnostics in parseSOAPString

Version 1.1.13

  • More diagnostics for invalid soap

Version 1.1.14

  • Change to 3 levels of logging. Handle an uncaught exception. Fixed typo in discovery message.

Version 1.1.15

  • Fix to cope with a single service.

Version 1.1.16

  • Fix to cope with a single video source.

Version 1.1.17

  • Fix to cope with a numeric serial number.

Version 1.1.18

  • Added an option to include a camera manually by specifying the IP and port.

Version 1.1.19

  • Fix to cope with custom services

Version 1.1.20

  • Fix error when manually adding a DVR

Version 1.1.21

  • Another fix error when manually adding a DVR

Version 1.1.22

  • Stop polling for camera check when logging more than errors so the log is not flooded.

Version 1.1.23

  • Added an option to the Advanced settings to select the motion trigger source.

Version 1.1.24

  • Added an option to set the event object ID.

Version 1.1.25

  • Stability improvements with regards to events.

Version 1.1.26

  • Added an option to disable a camera.
  • Small memory optimisation (removed homey-log library).

Version 1.1.27

  • Fix for adding multiple cameras on a different VLAN.

Version 1.1.28 & 29

  • Fixed issues with pull point subscription introduced in 1.1.26
  • Changed NOW to SNAPSHOT for the 'Live image.

Version 1.1.30

  • Fix for cameras that are not supporting pull refresh correctly

Version 1.1.31

  • Enhanced logging facility to help diagnose camera issues more easily.

Version 1.1.32

  • Added Minimum On Time to advanced settings. This will also determine the minimum time between image updates to restrict overloading Homey when a camera fires motion events in quick succession.

Version 1.1.33

  • Added support for line crossed, image too dark and storage broken alarms plus CPU usage report.

Version 2.0.0

  • Update to Homey SDK3.
  • Added support for cameras Audio alarm.

Version 2.0.1

  • Fixed setTimeout issue when adding a camera.

Version 2.0.2

  • Fixed missing flow card registrations.

Version 2.0.3

  • Fixed potential error when logging res.headers.raw().

Version 2.0.4

  • Updated all libraries to improve robustness of the app.

Version 2.0.5

  • Updated store images to current Athom store standards.

Version 2.0.6

  • Add more diagnostics for camera discover.

Version 2.0.7

  • Attempt each Auth mode if fetching a snapshot fails any time.

Version 2.0.8

  • Filtered flow cards so only applicable cards are shown.

Version 2.0.9

  • Uses the date and time for the device id if the mac address is not available…

Version 2.0.10

  • Fix to enable motion when the MOTION type is not supported but other types are.

Version 2.0.11

  • Extra error reporting.

Version 2.0.12

  • Extra error reporting.

Version 2.0.13

  • Extra error reporting.

Version 2.0.14

  • Made upstart functions synchronous in case the camera can’t cope with multiple simultaneous requests.

Version 2.0.15

  • Fixed an issue connecting to a camera that returns the firmware version as a number instead of a string.

Version 2.0.16

  • Increased Push notification buffer allowance.

Version 2.0.17

  • Added detection of RuleEngine/MyRuleDetector/Visitor to activate the alarm_generic.

Version 2.0.18

  • Added detection of RuleEngine/MyRuleDetector/Visitor:State to activate the alarm_generic.

Version 2.0.19

  • Try to reduce strange unhandled reject reports for handled rejection.

Version 2.0.20

  • Updated all libraries to improve robustness of the app.

Version 2.0.21

  • Fix a crash if the camera goes offline while renewing the push notifications

Version 2.0.22

  • Fix for NVR multi-channel events.

Version 2.0.23

  • Update ONVIF library.

Version 2.0.24

  • Log requests to track down SOAP error.

Version 2.0.25

  • Updated for compatibility with Homey 2023.

Version 2.0.26

  • Set option to ignore certificate errors to allow for self-signed https connection for snapshot.

Version 2.0.27

  • Fix potential crash when logging.

Version 2.0.28

  • Added alarms for People, Visitor, Face, Cat / Dog and Vehicle (note: support is camera dependent).

Version 2.0.29

  • Returned generic alarm for doorbell pressed…

Version 2.0.30

  • Fix for event token on individual cameras that was introduced when adding support for a NVR.

Version 2.0.31

  • Improved some error handling.

Version 2.0.32

  • Improved some error handling.

Version 2.0.33

  • Improved some error handling.

Version 2.0.34

  • Improved some error handling.

Version 2.0.35

  • Fix triggers for custom motion events.

Version 2.0.36

  • improved error handling

Version 2.0.37

  • Improved error handling

Version 2.0.38

  • Update ONVIF library.

Version 2.0.39

  • Fix camera timezone / DST.

Version 2.0.40

  • Added options to enable / disable time zone for camera times and add an offset to correct for DST."

Version 2.0.41

  • Trap for errors getting MAC address.

Great work, thx!
If not allowed by Homey, please publish it elsewhere, so we can sideload it…

It is on GitHub https://github.com/AdyRock/com.onvif
The more testing the better :wink:

I currently have two different cameras on it. One is an H.View HV-E800 and the other is an unbranded camera in a bird box.

Thanks to @Rocodamelshekima for pointing out that I had not included the onvif lib on GitHub. I have now added that and hopefully it should work.
Note: I have modified the original lib to make it work as it had several issues. I’m not sure if it is my cameras or general problems but it couldn’t cope with the returned data structures.

1 Like

And again thanks to @Rocodamelshekima for helping me find that there are a few other dependencies that the onvif lib relies on. These are now in the node_modules directory up on GitHub.

1 Like

My first submission was rejected because I had the description in the first line of the readme. But it has given me a chance to update it to the latest version.
It now uses the latest version of the ONVIF library which works without my modifications. i have also added capabilities to show when the motion event occured, when the camera went offline plus the time from the camera. Also there is now a maintenance button to set the camera time to Homey time.


Good work :grinning:

I hope to link my camera also with this to homey.
it now works with VLC http://123.456.789.0/videostream.asf?user=xxxxx&pswd=xxxxx.

Probably won’t work with my app as I spotted this on the link you gave:
De onvif protocol is niet ondersteund, en de maximale geheugenkaart is 128G!

sorry wrong link, it is

That looks more hopefully :grin:

Adrian, the app is live thanks for that. unfortunately the app does not find my camera. is there anything I can do to get it working?

The first release went live the is morning and there is now the first update available at:

Should hopefully fix a few bugs that have been discovered with the help of @Rocodamelshekima


Can you try the \test version linked above to see if that works?

Adrian. Version 005 installed. After 8 sec same error: no camera found. My Hdminicampro app has lost the camera also. I have removed the app 005 and installed it again on homey and restart the camera and after that my Hdminicampro app functioned again but the 005 version on homey did not find the camera after 8 sec. of searching the error: no camera found again. the Hdmincampro keeps working.

I have a crash dump from around 16:56 so not sure if that came from you (no identification is included with them).
That shows an invalid response from a camera couldn’t be handled by the ONVIF lib. Unfortunately it doesn’t show what the response was but I can see where better error handling is required so it doesn’t crash the app.
I will also add a log page like I have in my other apps so more diagnostic information can be gathered.
Watch this space for updates :wink:

Hello Adrian,
perhaps this was mine, 17:56 german summer time. Perhaps this ist the reason for the 1 hour difference.
I tried to search for cameras (HiKam S6 and Lutec lamp with camera).
The app doesn’t find a camera. It shows a timeout message.
Would it be possible to create a device with settings (IP, Port or URL) if the search doesn’t work?
I’ll wait for the new test version with some log information. Perhaps I can find the reason why search is not successful.
Thanks for this app. I would like to use it, because Athom added some checks for virtual cameras that prevents adding a valid URL (error message EHOSTUNREACH in Homey-app, but in Browser it’s ok).

I have posted a new test version 0.0.6.
This adds a log page to the Configure app in the Apps section of Homey. If you have issues then go to that screen and enable the logging. Then repeat the troublesome task, e.g. pairing, and when finished return to the log screen to view the diagnostics message. If you could send then to me by PM or create an issue on GitHub (link is in the app store by clicking on Report an issue) then I can try to improve the app.
To copy the log on Android you can long press on the log text until the menu pops up and then touch ‘Select All’ followed by ‘Copy’. After that you can paste the text into the target view.

I have also added extra error traps to the ONVIF library so hopefully the previous crashes will not happen.

The only problem is if the discovery fails then the forced connection will probably fail. Discovery is a mandatory feature of ONVIF, so provided the camera is ONVIF compliant then it ‘should’ work. As this is the first release there are possibly issues with my code at the moment. I only have H.View cameras and an unbranded camera in a bird box to test with, which are working fine.
The problem I can foresee is coping with the various revisions of the ONVIF protocol so that may take some help from users to get established.