Instantaneous camera metrics - rough UI for Home Assistant

csJosh

n3wb
Joined
May 4, 2023
Messages
26
Reaction score
23
Location
United States
Hi All,
I pulled together a bunch of instantaneous performance metrics from my Dahua cameras and NVR and made a crude display for them in Home Assistant. Here's what it shows:

Screenshot from 2023-12-27 13-54-50.png
It looks like it's possible to get the exposure numbers the camera is using, overall ambient brightness, video stream bandwidth going into the NVR, cpu usage, and memory usage.
The NVR always reports "2" for CPU usage - not sure why that is. Seems like it's a discrete enum of some sort rather than percentage value.
This is all through the 37777 interface.
I use the brightness number in some HA automations. I found the gain+exposure numbers useful for tuning the camera exposure settings.
The bandwidth (Kbps) has been a bit useful - I think the bandwidth usage goes up at night, I'm thinking it's because there's more noise in my image, which is harder to encode efficiently. I probably should turn up my NR settings a bit.
The cpu% and memory usage I haven't found to be actionable at all so far.
-Josh
 

actran

Getting comfortable
Joined
May 8, 2016
Messages
813
Reaction score
738
Good job.

What lovelace card are you using in HA for the above?
What Dahua API call(s) are you making?
 

csJosh

n3wb
Joined
May 4, 2023
Messages
26
Reaction score
23
Location
United States
Thanks. I wrote a custom card in javascript using customElements.define() and subclassing LitElement. Then in render() putting something like html1<ha-card><h1>...`. The guts of it is css grid.

For the APIs, I use the Dahua NetSDK at Dahua Partner Alliances . That uses the 37777 interface I think.
I built a linux server using that library that provides a simple socket interface and bridges to the Dahua devices.
Then I wrote a custom Home Assistant component that talks to the bridge server and populates a bunch of entities in HA.
Along the way I also added an interface to download video clips and convert to AVI (the Dahua PlaySDK has a conversion function).
As I write this down, I realized that it was kinda involved getting this all working.
 
Top