📰 Lovelace: RSS Feed Parser Plugin/List Card

I decided to start over a bit.

I went back to the original sensor.py file and changed the way it searches for the image.

The sensor.py file is found in “/config/custom_components/feedparser”

The image extraction code starts at line 91:

if 'image' in self._inclusions and 'image' not in entryValue.keys():
    images = []
    if 'summary' in entry.keys():
        images = re.findall(r"<img.+?src=\"(.+?)\".+?>", entry['summary'])
    if images:
        entryValue['image'] = images[0]
    else:
        entryValue['image'] = "https://www.home-assistant.io/images/favicon-192x192-full.png"

A better way to find the images is to use the keys, so I replaced the above code with the following:

 if 'image' in self._inclusions and 'image' not in entryValue.keys():
    images = []
    if 'summary' in entry.keys():
        images = re.findall(r"<img.+?src=\"(.+?)\".+?>", entry['summary'])
    if images:
        entryValue['image'] = images[0]
    else:
        if 'media_content' in entry.keys():
            image = entry['media_content'][0]['url']
        if image:
            entryValue['image'] = image
        else:
            entryValue['image'] = "https://www.home-assistant.io/images/favicon-192x192-full.png"

The configuration.yaml is updated to :

  - platform: feedparser
    name: Engineering Feed
    feed_url: 'https://www.is.fi/rss/tuoreimmat.xml'
    inclusions:
      - title
      - link
      - published
      - summary
      - image

After a restart the Development Tools : States for sensor.engineering_feed looks like:

entries:
  - link: 'https://www.is.fi/tiede/art-2000007828573.html'
    title: >-
      Tutkijat: Kolmas annos korona­rokotetta voisi pÀihittÀÀ uudet
      virus­muunnokset
    summary: >-
      LÀÀkeyhtiöt suunnittelevat jo uuden polven rokotteita, mutta vanhoillakin
      valmisteilla voitaisiin ehkÀ pÀrjÀtÀ uusia variantteja vastaan.
    published: 'Fri, Feb 26 02:12 PM'
    image: 'https://is.mediadelivery.fi/img/468/56a789fe58014e00b50aa1f9e6380026.jpg'
  - link: 'https://www.is.fi/ruokala/ajankohtaista/art-2000007828571.html'
    title: >-
      Parempi kuin nachopelti! ”MielettömĂ€ssĂ€ lohturuoassa” on helppo kastike,
      joka on kaupan purkkia parempaa
    summary: >-
      Sanna MansikkamÀen herkkupellissÀ juustokastike tehdÀÀn sekoittamalla
      kahta eri vegejuustoa ja nachot korvataan perunalla.
    published: 'Fri, Feb 26 02:12 PM'
    image: 'https://is.mediadelivery.fi/img/468/932c58cc657d408783e6f12f8bd25943.jpg'

Hope this helps


Thank you for a quick answer!
it helped me a lot!

Thanks :slightly_smiling_face:

Hey, since this website will shutdown at 15.3.2021 do you have searched or/and found an alternative to this RSS feed yet?
i noticed today, that your cool workaround isn’t working anymore=( and while we all are staying home, this has become a really important part of my configuration=)

Greetings

1 Like

I also noticed this today. Sad. I removed my pages and feedparaer and listcard with Netflix and prime feeds maybe I search for a replacement in the future. Haven’t found a suitable solution yet.

sadly, but I’ll bookmark this if something new will come im back in your team:) thanks for your fast reply and greetings from south-west to you=)

I figured out my own issue, but I don’t know how to fix it. As detailed here, base64.decodestring was already deprecated and was removed in Python 3.9. Thus- don’t update to Python 3.9 until this gets fixed or you’ll lose Feedparser.

@iantrich do you mind taking a look?

Hi ,is it possible to get multi level fields?
for example I want to display my grocy shopping list from a sensor

sensor output looks like this

products:
 - id: 19
   product_id: 52
   amount: 1
   note: Added for recipe 2021-01
   product:
     name: Red Pepper
     id: 52
     product_group_id: null
     available_amount: 0
     best_before_date: null
     barcodes: []
     product_barcodes: []
     amount_missing: null
     is_partly_in_stock: null


I can access product_id and other fields on that level fine, but I would like to get the name field, “Red Pepper”

I tried Product.name and [Product].[name] in my card config but no luck.
is it possible?

Hi, Since some days ago my feedparser has stoped working and I get below error printout from HA.
It seams that the feedparser is recently updated, do I have to update something or is this a bug?
Thanks for any help :slight_smile:
Matz


Downgrade to 1.2 until you ha version 2021.4 installed

Thanks for fast answer!

I’ve installed the feedparser component using HACS in my Home Assistant (latest version running in a Docker Container) and added the sample configuration into my configuration.yaml, and when I ‘check configuration’ I get this error:

Platform error sensor.feedparser - cannot import name 'SensorEntity' from 'homeassistant.helpers.entity' (/usr/src/homeassistant/homeassistant/helpers/entity.py)

Any ideas what this is telling me?

Hi @smithbill17, you seams to have the same problem as I have, please look att @iantrich answer above.
The only thing now with @iantrich answer is that I have upgraded to 2021.4 but it didn’t help so i hope there will be a fix.

Thanks @Matz. The suggestion from @iantrich is to either downgrade the component or upgrade HA, but I’m already on HA v2021.4.0 (running successfully in a Docker Container). The custom component is installed okay, I only get the error when adding the sample to configuration.yaml.

I upgraded to feedparser v0.1.5 via HACS and with my v2021.4.0 HA, everything is now working. I just need to figure out how to use it properly :slight_smile: Thanks @Matz for the pointer & to @iantrich for a great custom component.

I need a bit of Newbie help with this please:

  1. Using HA v2021.4.0
  2. Installed feedparser custom component v0.1.5 via HACS
  3. Installed list-card as a custom repo via HACS
  4. Added the sample code to my configuration.yaml and restarted HA okay
  5. Checked in Developer > States > sensor.engineering_feed and it’s full of RSS articles each with fields title, link and image
  6. I go to one of my Dashboards and add a Custom Card. In the code editor, I paste in the sample code, and I ‘simplified’ it for testing to be:
type: 'custom:list-card'
entity: sensor.engineering_feed
title: Engineering
columns:
  - title: Title
    field: title

I saved the Custom Card and all I get on my Dashboard is a Custom Card that has title ‘Engineering’ and column title ‘Title’ and absolutely no articles listed. Why are they not being pulled from the sensor? What am I missing?

I haven’t messed around with uilovelace.yaml or sensor.py or any other bits of code - I assume I don’t have to do that if I’ve used HACS to install the two components and used the Custom Card code editor?

Apologies in advance for asking a dumb Newbie question.

You need to specify the feed_attribute: entries

1 Like

Thank you! I thought I had tried that already and saw no difference, but I’ve just tried it again and it’s working now. I must’ve screwed it up when I tried it before. Thanks for the help.

Actually I’ve now found that my problem seems to be:

 - title: Description
   field: description

Whenever I include this field in the custom card, it fails to populate with any RSS articles. If I remove that title/field, then it works (the field is correctly defined in my configuration.yaml as shown in the example code).

I’m also only getting the Home Assistant logo as the article images, but I’m aware others have mentioned this in their posts - so I’ll read those messages more carefully to figure out that problem.

Am I correct in thinking this custom component is just not pulling all of the designated ‘included’ fields from the RSS feed?

I’ve tried multiple feeds and added/removed the ‘inclusions’ to no avail. When I use Developer Tools > States > sensor.engineering_feed here’s what I see:

entries:
  - title: >-
      Where will Prince Philip's body be held and moved to before he is laid to
      rest?
    link: >-
      https://www.mirror.co.uk/news/uk-news/prince-philip-dukes-body-held-23886320
    image: 'https://www.home-assistant.io/images/favicon-192x192-full.png'
  - title: >-
      TV schedule change explained as Emmerdale, Corrie and EastEnders not on
      tonight
    link: >-
      https://www.mirror.co.uk/tv/tv-news/emmerdale-coronation-street-eastenders-not-23886423
    image: 'https://www.home-assistant.io/images/favicon-192x192-full.png'
  - title: >-
      Travelodge currently has family rooms in Cornwall from ÂŁ20.75pp for the
      summer
    link: >-
      https://www.mirror.co.uk/travel/uk-ireland/travelodge-rooms-cornwall-20pp-july-23879194
    image: 'https://www.home-assistant.io/images/favicon-192x192-full.png'

The ‘image’ is always the HomeAssistant logo and the only fields pulled from the RSS are title, link and the home assistant image.

Does this custom component no longer work??

UPDATE:

Okay, I think I’ve understood my problem: if your configuration.yaml includes any ‘inclusion’ fields which don’t exist in the RSS feed, then it simply fails to pull back any of the subsequent fields into the sensor.

So now my configuration.yaml looks like this and pulls everything back:

  - platform: feedparser
    name: Engineering Feed
    feed_url: 'https://www.sciencedaily.com/rss/matter_energy/engineering.xml'
    date_format: '%a, %b %d %I:%M %p'
    inclusions:
    exclusions:

and I can use them in the list-card now.

Sorry if I’ve been spamming this thread a bit too much.

1 Like

im stucking at an related point, I got feed parser 0.1.5 installed on HassIO 2021.4.4 and I can’t get all info from my feed.
If I set title and summary I get my feed accordingly buuut I wanted to explore a bit further so added

  - platform: feedparser
    name: programm
    feed_url: 'https://www.texxas.de/tv/hauptsenderJetzt.xml'
    date_format: '%a, %b %d %I:%M %p'

but nothing also with

  - platform: feedparser
    name: programm
    feed_url: 'https://www.texxas.de/tv/hauptsenderJetzt.xml'
    date_format: '%a, %b %d %I:%M %p'
    inclusions:
    exclusions:

anyone an idea how to fix this? if I download the xml directly I can see some fields but they don’t get picked up (for instance: there is a field “descriptions” which doesn’t work, but with “summary” I get the information provided in this field)
 so im totally lost, thought I got a bit deeper to it but nope