Hi all,
First post on the forum so I’m sorry if this isn’t the correct category for this…
but I’m having trouble trying to understand how to use nested attributes in a certain integration.
So I’m using a HACS integration called
(GitHub - bremor/bureau_of_meteorology: Custom component for retrieving weather information from the Bureau of Meteorology. ) and trying to use the sensor “sensor.xxxx.warnings” to display the current Weather warnings for my area.
So when there’s an active warning it’s displayed like this…
And I want to display the short_title or title attribute in this integration
(GitHub - cataseven/Strip-Card: This custom card displays multiple Home Assistant entities in a sleek, horizontally scrolling ticker. With full support for global and per-entity customization, it lets you monitor system metrics, sensor data, or device states in a compact, dynamic format. )
The card I have set up is like this
type: custom:strip-card
duration: 40
transparent: true
show_icon: false
continuous_scroll: true
border_radius: 12px
card_width: 100%
entities:
- entity: sensor.REDACTED_warnings
name: Weather warning
attribute: warnings
value_color: "#f0f000"
name_color: "#f2761d"
But all that is displayed is “weather warnings: [ object object ]”
Any suggestions would be greatly appreciated!
This is how it’s displayed
You’re going to need to use the value_template option.
type: custom:strip-card
duration: 40
transparent: true
show_icon: false
continuous_scroll: true
border_radius: 12px
card_width: 100%
entities:
- entity: sensor.REDACTED_warnings
name: Weather warning
value_template: |
{{ states['sensor.REDACTED_warnings'].attributes.warnings[0].short_title }}
value_color: "#f0f000"
name_color: "#f2761d"
Whatever version of “Jinja2 templates” they are using in the card does not seem to support filters like map or using loops, so there doesn’t seem to be a good way to get multiple warnings if they exist. If that is something you want, you may need to handle that in a Template sensor
1 Like
I see, thank you so much for this,
{{ states['sensor.REDACTED_warnings'].attributes.warnings[0].short_title }}
that was exactly what I was trying to figure out with templates but just didn’t know how to do attributes,
Thank you heaps, I tested this and works great!
Let’s say there is a second warning along side the first, would the template be something like this?
{{ states['sensor.REDACTED_warnings'].attributes.warnings[1].short_title }}
Just changing the 0 > 1? And would just display the second alert? I’d probably just have a seperate hidden strip card for whenever there is a second alert.
Adelando:
Let’s say there is a second warning along side the first, would the template be something like this?
{{ states['sensor.REDACTED_warnings'].attributes.warnings[1].short_title }}
Just changing the 0 > 1? And would just display the second alert?
Yes, changing the number inside the square brackets will change which item from the warnings list is being used.
1 Like