📰 Lovelace: RSS Feed Parser Plugin/List Card

I am trying to use this card for my electricity provider announcements page. But this page comes in json format, no rss, also having hundreds of unrelated announcements. I was able to filter those using a python script and write to a local file.

However, i have 2 problems:

  1. These feedparser and feedreader components could not read local files
  2. Not sure if they can read json dictionaries.

Do you have any suggestions?

RSS is Atom or XML based; so no JSON support. You could potentially create a template sensor for it? Not sure.

Think i found the solution. Instead of using feedparser, i used REST API to POST the filtered json to the attributes section of a command_line sensor in my python script. I also set the total number of json messages as the state of the sensor.

So, the outcome is:
11

Just like i wanted
 But I have to work on the fit of the text in the column now
 Any help with this?

EDIT: Solved it by adding spaces to the long-nonspaced words (i.e.after commas)

First, thanks for this plugin. Nice work!

But, I got a problem with a RSS-feed I try to read.
The description also contains som extra info [CDATA], and because of that, it seems that the text in the description can’t be read.
<description><![CDATA[köttfÀrslimpa potatis grÀddsÄs lingonsylt och grönsaker]]></description>

The YAML-file looks like this:

platform: feedparser
name: GlÀntan
feed_url: 'https://skolmaten.se/glantans-forskola9/rss/weeks/'
date_format: '%a, %b %d %I:%M %p'
inclusions:
  - title
  - description
#    - link
#    - image
#    - language
#  - pubDate
#  exclusions:
#    - language

Only title works, not descripton.

Any ideas what to do?

I’m just using the feedparser python library for grabbing the individual fields. I know CDATA is valid XML, not sure if it is consider valid for an RSS feed :man_shrugging: Can’t think of a way around that without working with the actual feedparser library itself. I don’t see myself doing that anytime soon.

OK. Thanks for the answer.

According to this document it is valid.
http://www.rssboard.org/rss-encoding-examples

Thanks

Hi @Twit

Did you manage to get thee BBC feed working? I get the same object issue as you.

@iantrich I managed to get the sensor working however I require my template to display all the available titles from my xml url. How can I do that?

I have this so far:


- platform: feedparser
  name: Sky Tech Feed
  feed_url: 'http://feeds.skynews.com/feeds/rss/technology.xml'
  date_format: '%a, %b %d %I:%M %p'
  inclusions:
    - title

and this:

{{states.sensor.sky_tech_feed.attributes.entries[0].title}}

but the above only shows 1 title and not all. Is there any way to get all the available titles? mmind you the number of titles keep changing and are not constant.

@petro can you help please?

thanks.

{{states.sensor.sky_tech_feed.attributes.entries | map(attribute='title') | list | join(', ') }}
3 Likes

thanks alot @petro. it works fine however when I try and use it in an automation it throws up an error:
here is the automation:

- id: 'news_on_led_board'
  alias: News On Led Board
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: switch.livingroom_lights
      to: "on"
  action:
    - delay: '00:00:05'
    - service: mqtt.publish
      data_template:
        topic: "messageboard/messages"
        payload_template: '{ "message": "BBC News UK: {{states.sensor.bbc_news_feed.attributes.entries | map(attribute='title') | list | join(', ') }}

the error I get is:

2019-11-30 10:58:47 ERROR (SyncWorker_1) [homeassistant.util.yaml.loader] while parsing a block mapping
  in "/config/automations.yaml", line 29, column 9
expected <block end>, but found '<scalar>'
  in "/config/automations.yaml", line 30, column 121
2019-11-30 10:58:47 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while parsing a block mapping
  in "/config/automations.yaml", line 29, column 9
expected <block end>, but found '<scalar>'
  in "/config/automations.yaml", line 30, column 121

line 30, column 121 seems to be the problem which is the colon before the t in 'title'

any idea on how to resolve that?
thanks

A quick ‘side’ question

Can you please share your BBC News feed sensor?

http://feeds.bbci.co.uk/news/uk/rss.xml

1 Like

You’re trying to do some odd things with your payload and it looks like your missing your last } for the json.

try this

    - service: mqtt.publish
      data_template:
        topic: "messageboard/messages"
        payload:
          message: >
            BBC News UK: {{states.sensor.bbc_news_feed.attributes.entries | map(attribute='title') | list | join(', ') }}

Thanks a lot mate

I have RSS feed parser and list card working but I would like to filter the feed content and am not sure how to do it.
Config:

- platform: feedparser
  name: TFS Alerts
  feed_url: http://www.fire.tas.gov.au/Show?pageId=colBushfireSummariesRss&region=S&alertsOnly=true
  inclusions:
    - title
    - summary

This is what shows as the feed attributes in developer tools:

entries: [object Object],[object Object],[object Object],[object Object],[object Object]
friendly_name: TFS Alerts
icon: mdi:rss

If I click on the sensor I get this showing in the developer tools State attributes (YAML, optional):

entries:
  - title: Pelham and Elderslie areas
    summary: >-
      ALERT LEVEL: Advice<br /> Region: S<br /> LOCATION: Pelham and Elderslie
      areas<br /> STATUS: Going<br /> TYPE: VEGETATION FIRE<br /> SIZE: 2050
      Hectares<br /> Number of Vehicles: 14<br /> More Info: <a
      href="http://www.fire.tas.gov.au/a/81891">http://www.fire.tas.gov.au/a/81891</a><br
      /> RESPONSIBLE AGENCY: Tasmania Fire Service<br /> UPDATED: Sat, 4 Jan
      2020 13:18:04 +1100<br />
  - title: 'Broadmarsh, Black Brush and surrounding areas'
    summary: >-
      ALERT LEVEL: Advice<br /> Region: S<br /> LOCATION: Broadmarsh, Black
      Brush and surrounding areas<br /> STATUS: Going<br /> TYPE: VEGETATION
      FIRE<br /> SIZE: 2050 Hectares<br /> Number of Vehicles: 14<br /> More
      Info: <a
      href="http://www.fire.tas.gov.au/a/82195">http://www.fire.tas.gov.au/a/82195</a><br
      /> RESPONSIBLE AGENCY: Tasmania Fire Service<br /> UPDATED: Sat, 4 Jan
      2020 13:19:25 +1100<br />
  - title: 'Kempton, Hunting Ground and surrounding areas'
    summary: >-
      ALERT LEVEL: Advice<br /> Region: S<br /> LOCATION: Kempton, Hunting
      Ground and surrounding areas<br /> STATUS: Going<br /> TYPE: VEGETATION
      FIRE<br /> SIZE: 2050 Hectares<br /> Number of Vehicles: 14<br /> More
      Info: <a
      href="http://www.fire.tas.gov.au/a/82214">http://www.fire.tas.gov.au/a/82214</a><br
      /> RESPONSIBLE AGENCY: Tasmania Fire Service<br /> UPDATED: Sat, 4 Jan
      2020 13:20:40 +1100<br />
  - title: 'Bagdad, Green Valley, Cockatoo Gully and Dysart areas'
    summary: >-
      ALERT LEVEL: Advice<br /> Region: S<br /> LOCATION: Bagdad, Green Valley,
      Cockatoo Gully and Dysart areas<br /> STATUS: Going<br /> TYPE: VEGETATION
      FIRE<br /> SIZE: 2050 Hectares<br /> Number of Vehicles: 14<br /> More
      Info: <a
      href="http://www.fire.tas.gov.au/a/82215">http://www.fire.tas.gov.au/a/82215</a><br
      /> RESPONSIBLE AGENCY: Tasmania Fire Service<br /> UPDATED: Sat, 4 Jan
      2020 13:14:11 +1100<br />
  - title: 'Pearce Basin, Southwest'
    summary: >-
      ALERT LEVEL: Advice<br /> Region: S<br /> LOCATION: Pearce Basin,
      Southwest<br /> STATUS: Going<br /> TYPE: VEGETATION FIRE<br /> SIZE: 2700
      hectares<br /> Number of Vehicles: <br /> More Info: <a
      href="http://www.fire.tas.gov.au/a/81562">http://www.fire.tas.gov.au/a/81562</a><br
      /> RESPONSIBLE AGENCY: Parks and Wildlife Service<br /> UPDATED: Sat, 4
      Jan 2020 13:22:39 +1100<br />
friendly_name: TFS Alerts
icon: 'mdi:rss'

Basically I want to filter out entries with ALERT LEVEL: Advice. Is this possible?

I think you’ll need to create a template sensor based on the alerts on

Ok I think I can work with this:

{% for item in state_attr('sensor.tfs_alerts','entries') %}
  {% if 'ALERT LEVEL: Advice' not in item.summary %}
    {{ item.summary }}
  {% endif %}
{% endfor %}

hi all,
is this broken?
I get the: entries: [object Object], on the sensor state

and I can get the sensor attribute as a template sensor

but this can’t be used with the list card right?

The resulting sensor can be used by the list card, yes. Template would to be the correct format