Hi Home Assistant experts
I’ve created a rest sensor that captures the current days’ TV guide for UK’s BBC 1. I’m trying to set the state of the sensor to the current programme name. Here’s my Yaml so far:
# TV Listings
- resource: "https://www.freesat.co.uk/tv-guide/api/0?channel=560"
scan_interval: 28800
sensor:
- name: Freesat BBC One
value_template: >-
{% for event in value_json ??? %}
{% if event.startTime < as_timestamp(now()) and event.startTime + event.duration > as_timestamp(now())%}
{{ event.name }}
{% endif %}
{% endfor %}
json_attributes_path: "$.0"
json_attributes:
- event
Do you know what I should use where I have the ‘???’ to get the collection of events?
Here’s a sample of what the web request returns:
[
{
"channelid": 560,
"offset": 0,
"event": [
{
"name": "Breakfast",
"description": "The latest news, sport, business and weather from the BBC's Breakfast team. [S] [HD]",
"startTime": 1721106000,
"duration": 12600,
"svcId": 560,
"evtId": 26072,
"image": "/ms/img/epg/rb/ae0c-p0fxfnwr.jpg",
"hasTstv": true,
"tstv": {
"sid": 919,
"availabilityStart": 1721116800,
"availabilityEnd": 1721204940,
"mediaAvailable": false,
"mediaLocation": "channel=919&programmeid=_DTT_m002150w&ui_id=4.0.0"
}
},
{
"name": "Morning Live",
"description": "Join Gethin Jones, Helen Skelton, Michelle Ackerley and the team for conversation, advice and tips to make your day that little bit easier. [S] [HD]",
"startTime": 1721118600,
"duration": 4500,
"svcId": 560,
"evtId": 26073,
"image": "/ms/img/epg/rb/ae0c-p0j52029.jpg",
"hasTstv": true,
"tstv": {
"sid": 919,
"availabilityStart": 1721123095,
"availabilityEnd": 1752659095,
"mediaAvailable": false,
"mediaLocation": "channel=919&programmeid=m002150y&ui_id=4.0.0"
},
"seriesNo": 6,
"episodeNo": 57
}
]
}
]
Thanks