Skip to content

Filtering #61

Description

@nTx-Cheerok

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.

Activity

  1. macross5 commented on Apr 4, 2023

    @macross5

    i would love it aswell

  2. macross5 commented on Apr 4, 2023

    @macross5

    @nTx-Cheerok can you show me an example for the templating?

  3. Vitani commented on Apr 4, 2023

    @Vitani

    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.

  4. macross5 commented on Apr 4, 2023

    @macross5

    I 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 }}
        `
  5. nTx-Cheerok commented on Apr 5, 2023

    @nTx-Cheerok
    Author

    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.

  6. ogajduse commented on Jul 27, 2023

    @ogajduse
    Collaborator

    @Vitani Could you post the URLof the RSS feed that you use for weather alerts here?

  7. Vitani commented on Jul 27, 2023

    @Vitani

    @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&amp;id=da1b66c8-0df8-49f0-a6a5-7f255d0cb8a9&amp;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&amp;id=da1b66c8-0df8-49f0-a6a5-7f255d0cb8a9&amp;referrer=rss&amp;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&amp;id=2be5c1e8-2717-45ac-a32e-581b313e9943&amp;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&amp;id=2be5c1e8-2717-45ac-a32e-581b313e9943&amp;referrer=rss&amp;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 description contains "Leicester" then it is shown (so in the example above I would only see the "Yellow warning of thunderstorm" item

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions