Skip to content

Instantly share code, notes, and snippets.

@MichaelMKKelly
Last active April 11, 2025 17:50
Show Gist options
  • Save MichaelMKKelly/86731c02de82ad1891ca515548e7baa7 to your computer and use it in GitHub Desktop.
Save MichaelMKKelly/86731c02de82ad1891ca515548e7baa7 to your computer and use it in GitHub Desktop.
Feedreader Example

Example of using Feedreader Integration to display recent news on dashboard

First add the feed you want using the UI

image

and enter your feed URL

image

to be sure to only get the latest news item configure the integration

image

and set to 1 entry

image

now you want to set up some text helpers to hold the data

image

image

ENSURE THEY ARE SET TO A MAX LENGTH OF 255

you should make one for:

RSS Title

RSS Description

RSS Link

RSS Date

now we need to fill these with data from the integration when new news arrives by triggering on the event

example automation:

alias: RSS Feed Reader
description: ""
triggers:
  - trigger: event
    event_type: feedreader
    event_data:
      feed_url: https://newsletter.openhomefoundation.org/rss/
conditions: []
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: " {{ trigger.event.data.title }} "
    target:
      entity_id: input_text.rss_title
  - action: input_text.set_value
    metadata: {}
    data:
      value: " {{ trigger.event.data.description }} "
    target:
      entity_id: input_text.rss_description
  - action: input_text.set_value
    metadata: {}
    data:
      value: " {{ trigger.event.data.link }} "
    target:
      entity_id: input_text.rss_link
  - action: input_text.set_value
    metadata: {}
    data:
      value: " {{ trigger.event.data.published }} "
    target:
      entity_id: input_text.rss_date
mode: single

you should change the URL to match your feeds URL and update the helper entities as needed to point to where you want the data.

now you can create a markdown card on your dashbaord to display the information from the feed

example card:

type: markdown
content: |-
  ## {{states('input_text.rss_title')}}
  ### {{states('input_text.rss_description')}}
   {{states('input_text.rss_link')}}
   
   {{states('input_text.rss_date')}}
title: Latest From The Open Home Foundation

should look like this:

image

if it is currently showing no data you can either wait for the next RSS announce or you can reload the integration to force it to grab the most recent news item

@wormuths
Copy link

Good day,

One thing I've learned from trial and error is the input text helpers have indigestion if the description returned is over 255 characters. Helpers are limited to 255 and the automation will fail. With a little help from ChatGPT, I've tested this which appears to work for stripping HTML tags and truncating what's passed to the helper.

{{ trigger.event.data.summary | striptags | truncate(250, True, '...') }}

I can test it again alongside your more knowledgeable advice, but I had problems setting the feed to "1". This is exactly what I want to do, but when I used "1" last night, the feed had not updated for 12 hours. The feed did not have any logbook entries about "detecting an update" , so nothing changed all night. I updated it to "2" and the feed immediately updated. Likely just because it forced a reload, but the single entry sat without firing for 12 hours.

Right now it's at "2", and I'll see if it updates in the next couple hours.

It's also not clear if the feed refreshes each time a new feed is published, or just once an hour. Reading around will get you both answers, because the configuration change to UI Setup killed the ability to specify the update interval in YAML. So a newcomer won't know it's just once an hour, and think it's not working at all. Someone in my situation has to make a change, and then wait a couple hours to see if the changes broke anything. It's very flaky and time consuming.

Right now, I have this automation.

triggers:
  - event_type: feedreader
    event_data:
      feed_url: https://feeds.feedburner.com/breitbart
    alias: RSS Feed Updated (Breitbart News)
    trigger: event
conditions: []
actions:
  - alias: Update Helper (Breitbart News Date)
    action: input_datetime.set_datetime
    metadata: {}
    data:
      timestamp: >-
        {{ as_timestamp(strptime(trigger.event.data.published, '%a, %d %b %Y
        %H:%M:%S %z')) | int }}
    target:
      entity_id: input_datetime.rss_breitbart_date
    enabled: false
  - action: input_text.set_value
    metadata: {}
    data:
      value: "{{ trigger.event.data.title }}"
    target:
      entity_id: input_text.rss_breitbart_title
    alias: Update Helper (Breitbart News Title)
  - action: input_text.set_value
    metadata: {}
    data:
      value: >-
        {{ trigger.event.data.summary | striptags | truncate(165, True, '...')
        }}
    target:
      entity_id: input_text.rss_breitbart_description
    alias: Update Helper (Breitbart News Description)
  - action: input_text.set_value
    metadata: {}
    data:
      value: "{{ trigger.event.data.link }}"
    target:
      entity_id: input_text.rss_breitbart_link
    alias: Update Helper (Breitbart News Link)
mode: single

I currently have the section for updating the datetime helper disabled, because I've gotten errors about formatting. I'm going to set it back to your value entry for now. You have a text helper, not a datetime?

I'm happy to help you get some better documentation any way I can. Maybe it can help others be less frustrated. Current news is a great feature for dashboards, so this is a worthy cause.

@MichaelMKKelly
Copy link
Author

@wormuths
yeah input text is limited to 255 so stripping it down to that to prevent errors is a good idea

on the date point. I had a go at making it work and it was a bit of chaos as in RSS feeds it comes from in rfc-822 format which has some variations. I figured for simple example to display a date then just text would be easier.

I did get a semi working version but I had to strip the timezone out and could not figure a way to put it back in
this is where i got to playing in the template editor in the dev tools if you you want to play with it

{% set input = 'Mon, 31 Mar 2025 15:47:37 GMT' %}
{% set splitdate = input.split(' ') %}
{% set timezone = splitdate[(splitdate|length -1)] %}
{% set time_without_tz = input[:(input|length - (timezone|length + 1) )  ] %}
{% set parseFormat ='%a, %d %b %Y %H:%M:%S' %}
{% set real_datetime = strptime(time_without_tz, parseFormat) %}

{{real_datetime}}

my string manipulation is a bit of a mess but you can see what I am getting at and can refactor it if you like.

I don't really use the integration that much myself so need to dive in a bit.
there is also a parsed date object as part of the event so you could rebuild the format from that but I think that was missing the timezone section.

I am sure someone with more knowledge than me could make something better but perhaps adding to the integration itself might be a better option to be honest.

@wormuths
Copy link

I'd be happy just having it input the date/time from when it was updated, as in, when the feed was entered into the helper. Basically, the time I added the headline, rather than the exact second it was published. Exact doesn't matter to me (might for some), as it's just a general guideline...

But this integration IS seriously lacking. Changing the number of feeds isn't making a difference. Once again, nothing is downloading for me. I thought it was because the feeds were set to "1", so I changed it to "2". It's made no difference, and nothing is updating because the integration says it isn't detecting anything.

Screenshot_20250411_132005

Screenshot_20250411_132101

The last update happened around midnight last night, and now it no longer updates. Last time this required a restart to fix. There are no errors in the logs, and what's worse, there is NO WAY to disable system polling and use an automation to fire the "feedreader" event on a defined schedule to force it. If it stops, it just stops. No warning, nothing...

I'm setting back to one feed, and restarting. I'll see how it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment