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:
These feedparser and feedreader components could not read local files
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.
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
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 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.
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.
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'
{% for item in state_attr('sensor.tfs_alerts','entries') %}
{% if 'ALERT LEVEL: Advice' not in item.summary %}
{{ item.summary }}
{% endif %}
{% endfor %}