I finally got around to play with this and got it to work quite easily with some help from ChatGPT, which saved me some time.
Nothing really complicated, Home Assistant makes it quite easy.
Step 1: create a new sensor in /config/configuration.yaml:
sensor:
- platform: rest
resource: http://192.168.0.155:8089/dvr
name: channels_dvr_disk_space
value_template: '{{ value_json.disk.free }}'
(YAML code accurately generated by ChatGPT)
--- Edit (5/14/2023) ---
This sensor as written returns the disk size in bytes, which is a big number with a lot of digits and that is not easy to digest. You can make it easier to use with this slight optimization:
sensor:
- platform: rest
resource: http://192.168.0.155:8089/dvr
name: channels_dvr_disk_space
value_template: '{{ value_json.disk.free | int / (1024*1024*1024)) | round(2) }}'
Now it will have the value 102.89 instead of 110477296271. This is the way you see it on the server's web UI too.
This simplifies automations too because you can use simple numbers, such as 100 or 50.
--- End of edit ---
Make sure to use the IP address of your Channels DVR server in the "resource" field.
Step 2: restart Home Assistant to load the new configuration
Step 3: create an automation that uses the numeric state of this new sensor as a trigger and performs any actions you wish (send a mobile notification, send an email or SMS, flash some lights, make an announcement in your house on your smart speakers, etc.)
For example, as a quick test, I created an automation that sends me a notification in the Home Assistant Android companion app when the disk space on the DVR falls below 100 GB, which actually happened earlier before I started typing this post.
Notification received on my phone:
I prefer to use the UI as much as possible to create automations and this is what it looks like:
Here is the YAML version of the automation:
alias: Channels DVR Disk Space
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.channels_dvr_disk_space
below: 100
alias: Less than 100 GB left on DVR
id: Less than 100 GB
condition: []
action:
- service: notify.mobile_app_gildas_cell
data:
message: Disk space on DVR below 100 GB
title: Low disk space on Channels DVR
mode: single
I will extend this automation so that it sends me a text when the disk space drops below 75 GB and, additionally, make an announcement in the house on my Google Nest speakers when it drops below 50 GB.
Once you have this sensor, the possibilities are endless with Home Assistant for what actions you want to perform.
This is fun and actually useful.
I hope this helps somebody.