Hi All
I thought I’d add some info on how I’m using the Scheduled Recording Info that Roger kindly added in the latest release following my request on Github, this might be useful to some particularly around querying the attributes within the “recording” array as the array only exists when the box is actually recording and isn’t a simple state_attr type query and took me a while to get right.
Firstly some code I use on my dashboard to show the status, showing what’s recording if anything, what’s next scheduled to record and when, and the disk space. Obviously change the sensor.sky_q_living_room_schedule sensor to your own sensor name then put the code in a Markdown card (as it allows som basic formatting). I’m not sure what happens to this if no future schedule is set so probably needs some error checking although we’ve always got series links scheduled so I’ve not got the need to handle that scenario.
{% set recordings = state_attr('sensor.skyq_schedule', 'skyq_recordings') %}
{% if recordings is sequence and recordings|length > 0 and recordings[0].skyq_recording_title is defined %}
**Recording Now:** {{recordings[0].skyq_recording_title }}
{{as_timestamp (recordings[0].skyq_recording_start) | timestamp_custom('**Started:** %H:%M') }}
{{as_timestamp (recordings[0].skyq_recording_end) | timestamp_custom('**Ends:** %H:%M') }}
{% else %}
**Not Recording**
{% endif %}
**Next Recording:** {{state_attr ('sensor.skyq_schedule', 'skyq_scheduled_title')}}
{{ as_timestamp(state_attr('sensor.skyq_schedule', 'skyq_scheduled_start')) | timestamp_custom('Starts: %A %dth %H:%M') }} (in {{states ('sensor.minutes_next_sky_recording')}} minutes )
{{ as_timestamp(state_attr('sensor.skyq_schedule', 'skyq_scheduled_end')) | timestamp_custom('Ends: %A %dth %H:%M') }}
**Disk Capacity Remaining:** {{states ('sensor.skyq_used_storage')}}Gb ( {{state_attr ('sensor.skyq_used_storage', 'skyq_storage_percent')}}% )
I also added the following 3 sensors in my sensor.yaml so I can trigger automations based on the recording status of the main box and mini, turning it off overnight via a smart switch when not recording and the box or our mini isn’t active, and turn back on when the time to next recording is less than 10 minutes for example.
skyq_minutes_next_recording:
friendly_name: "Minutes until Next Sky Q Recording"
unit_of_measurement: "m"
value_template: >-
{{((state_attr('sensor.skyq_schedule', 'skyq_scheduled_start')|as_timestamp|int -
now()|as_timestamp|int)/60)|int}}
skyq_recording_status:
friendly_name: "Sky Q Main Box is Recording"
value_template: >
{{state_attr('sensor.skyq_schedule', 'recordings') is not none}}
skyq_in_use:
friendly_name: "Sky Q in use"
value_template: >
{{is_state('media_player.sky_q_living_room', 'playing')
or is_state('media_player.sky_q_mini_kitchen', 'playing')
or is_state('media_player.sky_q_living_room', 'paused')
or is_state('media_player.sky_q_mini_kitchen', 'paused')}}
Hope this helps someone
cheers
Edited to update formatting