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…
(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;
This should probably be moved to the “Share your projects” category.
It is a textbook example for that category and it should not be buried in questions in the configuration category and then forgotten in a few days.
I found some time to work this out for you… actually it was pretty easy in the end…
So this now puts the current event into the State for the Sensor.
My next little play is to spin up a new sensor to capture the now-playing image of the current programme so I can put it on the wall mounted tablets running Home Remote.
# EPG Collectors
- platform: rest
resource: "https://www.freesat.co.uk/tv-guide/api/0?channel=560"
scan_interval: 28800
name: EPG_BBCOne
value_template: >-
{% set ns = namespace(counter=0) %}
{% for time in value_json.0.event %}
{% if ns.counter == 0 %}
{% if (as_datetime(time.startTime+time.duration)+timedelta(hours=0) > now()) %}
{% set ns.counter = ns.counter + 1 %}
{{ (as_datetime(time.startTime)+timedelta(hours=1)).strftime("%H:%M")}} : {{time.name}}
{% endif %}
{% endif %}
{% endfor %}
json_attributes_path: "$.0"
json_attributes:
- event
With a 28800 scan interval, I went back to the original naming, and the value_template is too slow.
No point storing the images, they change too often.
Current program image is displayed. Today’s task is to have a look at having just the one card displaying the current channel. I’m not sure if it would be better but it’s fun tinkering!