I have newsitems from a rss-feed in listcard. Because that takes a lot of space on my frontpage, I would like to have those news-items as a marquee (when that is possible).
I don’t know how to fill the template. Perhaps someone does ?
This is the code for the marquee :
type: custom:button-card
name: >
[[[return `<div style='display: flex;display: -webkit-flex;'>
<div>Ha Rpi4 alerts: </div>
<marquee>
<span style='color: red;'>
news1: ${states['sensor.nunieuws'].state}, 
news2: {{state_attr('sensor.nunieuws', 'title')}}, 
</span>
<span style='color: var(--primary-color);'>
System alerts: ${states['sensor.nunieuws'].state} </span>
<span style='color: green;'>
Summary - ${states['sensor.nunieuws'].state}, 
Daily - ${states['sensor.nunieuws'].state} 
Hourly - ${states['sensor.nunieuws'].state}
</span>
</marquee>`]]]
renespit
(Rene Spit)
January 19, 2024, 9:57am
2
I think the best way is to use feedparser GitHub - custom-components/feedparser: 📰 RSS Feed Integration
Put something like this in your configuration.yaml:
sensor:
- platform: feedparser
name: Nu News Feed
feed_url: 'https://www.nu.nl/rss/Algemeen'
date_format: '%a, %d %b %Y %H:%M:%S %Z'
scan_interval:
minutes: 6
inclusions:
- title
- link
exclusions:
- description
- image
- pubDate
- language
After a restart you can add a buttoncard to your view:
type: custom:button-card
card_mod:
style: !include /config/lovelace/css/v2.0/card/rss/minimal.css
name: >
[[[return `
<marquee scrollamount=25 style="text-transform: uppercase; font-family: 'Lucida Console', 'Courier New', monospace; font-size: 72px; font-weight: bold; width: 100%; background-color: var(--app-header-background-color); vertical-align: middle;">
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.telegraaf_news_feed'].attributes.entries[0].title }
</span>
<span style="background-color: var(--app-header-background-color); color: yellow; vertical-align: middle; text-transform: uppercase;">
Temperatuur ${ states['weather.buienradar'].attributes.temperature }${ states['weather.buienradar'].attributes.temperature_unit }
</span>
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.nos_news_feed'].attributes.entries[0].title }
</span>
<span style="background-color: var(--app-header-background-color); color: orange; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.telegraaf_news_feed'].attributes.entries[1].title }
</span>
<span style="background-color: var(--app-header-background-color); color: yellow; vertical-align: middle; text-transform: uppercase;">
Temperatuur morgen,
max ${ states['weather.buienradar'].attributes.forecast[0].temperature }${ states['weather.buienradar'].attributes.temperature_unit }
min ${ states['weather.buienradar'].attributes.forecast[0].templow }${ states['weather.buienradar'].attributes.temperature_unit }
</span>
<span style="background-color: var(--app-header-background-color); color: orange; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.nos_news_feed'].attributes.entries[1].title }
</span>
<span style="background-color: var(--app-header-background-color); color: yellow; vertical-align: middle; text-transform: uppercase;">
Woonkamer temperatuur ${ states['climate.nefit'].attributes.current_temperature }${ states['weather.buienradar'].attributes.temperature_unit }
Ingestelde temperatuur ${ states['climate.nefit'].attributes.temperature }${ states['weather.buienradar'].attributes.temperature_unit }
</span>
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.telegraaf_news_feed'].attributes.entries[2].title }
</span>
<span style="background-color: var(--app-header-background-color); color: yellow; vertical-align: middle; text-transform: uppercase;">
Energie productie vandaag ${ states['sensor.envoy_122323024158_today_s_energy_production'].state }Wh
</span>
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.nos_news_feed'].attributes.entries[2].title }
</span>
<span style="background-color: var(--app-header-background-color); color: orange; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.telegraaf_news_feed'].attributes.entries[3].title }
</span>
<span style="background-color: var(--app-header-background-color); color: yellow; vertical-align: middle; text-transform: uppercase;">
Energieprijs gemiddeld ${ states['sensor.energyzero_today_energy_average_price'].state }${ states['sensor.energyzero_today_energy_average_price'].attributes.unit_of_measurement }
energieprijs nu ${ states['sensor.energyzero_today_energy_current_hour_price'].state }${ states['sensor.energyzero_today_energy_average_price'].attributes.unit_of_measurement }
energieprijs maximaal vandaag ${ states['sensor.energyzero_today_energy_max_price'].state }${ states['sensor.energyzero_today_energy_average_price'].attributes.unit_of_measurement }
</span>
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.nos_news_feed'].attributes.entries[3].title }
</span>
<span style="background-color: var(--app-header-background-color); color: orange; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.telegraaf_news_feed'].attributes.entries[4].title }
</span>
<span style="background-color: var(--app-header-background-color); color: lightblue; vertical-align: middle; text-transform: uppercase;">
${ states['sensor.nos_news_feed'].attributes.entries[4].title }
</span>
<\marquee>
`]]]
Note I have added more then 1 rss-news-feeds to my configuration.yaml.
Hi Renespit,
Did not expect an answer anymore, but after three years there it is Appreciate it !!
Is it possible to share the CSS-file too ? I am not very experienced with css.
Thanks in advance