I got inspired by @Ahwman in this thread:
That got me thinking about monitoring the DVR activity in real time and more specifically what it is recording. I came up with this sensor in Home Assistant:
sensor:
- platform: rest
name: channels_dvr_recordings
resource: http://192.168.4.100:8089/dvr
value_template: >
{% set recordings = namespace(list=[]) %}
{% for key, value in value_json.activity.items() %}
{% if 'Recording' in value %}
{% set program_name = value.split(' for ')[1].split(' until')[0].strip() %}
{% set recordings.list = recordings.list + [program_name] %}
{% endif %}
{% endfor %}
{% if recordings.list | length == 0 %}
No recordings in progress
{% else %}
{{ recordings.list | join(', ') }}
{% endif %}
scan_interval: 60
This sensor in Home Assistant will check every minute what the DVR is recording and will contain a string with the names of all the programs currently being recorded. Something like this:
As seen in Channels itself:
So what can you do with this?
Well, you can use it as a trigger to check if a specific program is being recorded.
Here is an example of automation to match what @Ahwman wanted to achieve:
- id: '<Redacted>'
alias: NHL Hockey is being recorded
description: ''
trigger:
- platform: state
entity_id:
- sensor.channels_dvr_recordings
condition:
- condition: template
value_template: '{{ ''NHL Hockey'' in states(''sensor.channels_dvr_recordings'')
}}'
action:
- action: <turn the TV on, whatever...>
In this post, the main focus was to retrieve the current recordings but you could easily tweak the sensor to monitor other activities from the DVR (the part {% if 'Recording' in value %}
) and do whatever.
Some ideas:
- if the DVR is busy recording, turn a light on in red
- if somebody starts watching something from the library, dim the lights in the room
Really whatever, this is Home Assistant after all, the possibilities are endless.
I hope this is useful for somebody.