Repository navigation
Filtering #61
Description
Activity
i would love it aswell
@nTx-Cheerok can you show me an example for the templating?
Me too, I use an RSS feed for weather alerts; the feed covers an entire region, but lists the cities affected in the "locations" field of each alert; it'd be nice to stick a regex on that field to only show alerts which affect my city.
Reacted by macross5I scripted the last hours and got this to work:
`
template:- sensor:
- name: "(TEST) RSS"
state: "{{ states('sensor.rss_feed') | int }}"
attributes:
entries: >-
{% set rss_list = namespace(entries=[]) %}
{% for entries in state_attr('sensor.rss_feed','entries') -%}
{% if "filter1" in entries['title']|lower
or "filter2" in entries['title']|lower
or "filter3" in entries['title']|lower
-%}
{% set rss_list.entries = rss_list.entries + [entries] %}
{% endif -%}
{% endfor %}
{{ rss_list.entries }}
`
- name: "(TEST) RSS"
- sensor:
Hi peops, i was very busy and this also kind of an old post :D
I switched setups and erased some stuff, including the stuff i needed the feed parser for.
Ill see if i can find my old backups as the config must still be in there and post my example.Reacted by macross5@Vitani Could you post the URLof the RSS feed that you use for weather alerts here?
@ogajduse this is the specific one I use - http://www.metoffice.gov.uk/public/data/PWSCache/WarningsRSS/Region/em, but there are more of them - https://www.metoffice.gov.uk/weather/guides/rss
Not sure how useful they will be right now, as there are currently no weather warnings in place for the UK
Edit: There are rain & thunderstorm warnings today, here's the feed -
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <title>Met Office warnings for East Midlands</title> <link>https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings</link> <description>Weather warnings of severe and extreme weather from the Met Office</description> <language>en-gb</language> <copyright>(c) Crown copyright</copyright> <pubDate>Wed, 02 Aug 2023 08:32:41 GMT</pubDate> <dc:creator>webteam@metoffice.gov.uk</dc:creator> <item> <title>Yellow warning of thunderstorm affecting East Midlands</title> <link>https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2023-08-02&id=da1b66c8-0df8-49f0-a6a5-7f255d0cb8a9&referrer=rss</link> <description>Yellow warning of thunderstorm affecting East Midlands: Derby, Derbyshire, Leicester, Leicestershire, Lincolnshire, Northamptonshire, Nottingham, Nottinghamshire, Rutland valid from 0800 Wed 02 Aug to 1900 Wed 02 Aug</description> <guid isPermaLink="false">https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2023-08-02&id=da1b66c8-0df8-49f0-a6a5-7f255d0cb8a9&referrer=rss&region=East Midlands</guid> <enclosure length="109337" type="image/png" url="https://cdn.prod.weathercloud.metoffice.gov.uk/warnings/rss/image/yellow-thunderstorm.png"/> </item> <item> <title>Yellow warning of rain affecting East Midlands</title> <link>https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2023-08-02&id=2be5c1e8-2717-45ac-a32e-581b313e9943&referrer=rss</link> <description>Yellow warning of rain affecting East Midlands: Lincolnshire, Nottinghamshire valid from 1000 Wed 02 Aug to 1900 Wed 02 Aug</description> <guid isPermaLink="false">https://www.metoffice.gov.uk/weather/warnings-and-advice/uk-warnings#?date=2023-08-02&id=2be5c1e8-2717-45ac-a32e-581b313e9943&referrer=rss&region=East Midlands</guid> <enclosure length="98657" type="image/png" url="https://cdn.prod.weathercloud.metoffice.gov.uk/warnings/rss/image/yellow-rain.png"/> </item> </channel> </rss>I would like to filter these items so that if the
descriptioncontains "Leicester" then it is shown (so in the example above I would only see the "Yellow warning of thunderstorm" item
Hi im using this component for some time now and it generellay works great with the custom lovelace card. However i was wondering if i could filter the entries of a feed efficiently without the need to fiddle around with template sensors.
Like only show titles that include a certain string or something like that. The reason i ask is that i kind of get it working with templates but not optimally.