Hi all.
I searched for a way to add a TV Guide that I can display on wall mounted tablets. There were a couple of posts, but nothing really explained how to get a good TV Guide, so I just did it myself and I am pretty pleased with the result so I thought I would share.
There are two parts… COLLECTION, and DISPLAY.
Collection is using a Rest Sensor in your Configuration.yaml. You will want one for every TV Channel you want to collect data for…
# EPG Collectors
- platform: rest
resource: "https://www.freesat.co.uk/tv-guide/api/0?channel=560"
scan_interval: 28800
name: EPG_BBCOne
value_template: "BBC One"
json_attributes_path: "$.0"
json_attributes:
- event
You can see here that I am collecting BBC One from the Freesat API on channel 560. You can easily find the channel number from the Freesat API here;
This will create a new sensor (once restarted) that will look like this;
(The attribute does get truncated in the picture, but you get the gist…).
Now you have the Sensor and the Attribute with all of the TV Guide in for the day, you can add it to your dashboard with a little Markdown Card as follows;
<div style="text-align:center">
<img src="/local/media/images/BBCOneHD_uk.jpg" alt="Amazon Music"/>
</div>
<b>{{ states('sensor.epg_bbcone') }}</b>
{% set ns = namespace(counter=0) %}
{% for time in states.sensor.epg_bbcone.attributes.event -%}
{% if ns.counter == 0 %}
{% if (as_datetime(time.startTime+time.duration)+timedelta(hours=0) > now()) %}
{% set ns.counter = ns.counter + 1 %}
<b><h2>{{ (as_datetime(time.startTime)+timedelta(hours=1)).strftime("%H:%M")}} : {{time.name}}</b></h2>
{{ time.description}}<br>
<img src="upload://9GHxzX9iFBeNiOjEsaSAyF1SiOn.jpeg">
{% endif %}
{% else %}
{% if (as_datetime(time.startTime)+timedelta(hours=0) > now()) %}
<details>
<summary>
{{ (as_datetime(time.startTime)+timedelta(hours=1)).strftime("%H:%M")}} : {{time.name}}
</summary>
<br>{{ time.description}}<br><p>
<img src="upload://9GHxzX9iFBeNiOjEsaSAyF1SiOn.jpeg">
</details>
{% endif %}
{% endif %}
{% endfor %}.
This will now give you a lovely dashboard view of your favourite channels like so…
Obvs, the way you lay out your card on your dashboard is tots up to you.
Hope this is useful to someone.


