alkan
(Adrián)
October 9, 2020, 9:38am
1
Hi!
We know that to get the state of an attribute of an entity it is done in the following way:
- type: state-label
entity: weather.casa
attribute: temperature
suffix: ' °C'
But if the entity has sub-attributes, how is it done? These examples don’t work.
- type: state-label
entity: weather.casa
attribute: forecast.0.temperature
suffix: ' °C'
- type: state-label
entity: weather.casa
attribute: forecast[0].temperature
suffix: ' °C'
Thanks!
1 Like
did you find the solution ? I am currently facing the same issue.
Can anyone figure this out?
I don’t suppose there’s been any update or solution to this?
artpcpl
(Artpcpl)
January 4, 2023, 1:55am
5
type: picture-elements
elements:
- type: state-label
entity: vacuum.robot_odkurzajacy
style:
top: 15%
left: 20%
color: darkred
font-size: 20px
- type: state-label
entity: vacuum.robot_odkurzajacy
attribute: error
style:
top: 25%
left: 20%
color: darkred
font-size: 18px
- type: state-label
entity: vacuum.robot_odkurzajacy
attribute: battery_level
prefix: 🔋
suffix: '%'
style:
top: 50%
left: 18%
color: mediumseagreen
font-size: 18px
- type: state-label
entity: vacuum.robot_odkurzajacy
attribute: cleaning_time
suffix: min
prefix: 'Czas Czyszczenia: '
style:
top: 9%
left: 80%
color: darkred
- type: state-label
entity: vacuum.robot_odkurzajacy
attribute: cleaning_area
suffix: m2
prefix: 'Powierzchnia: '
style:
top: 17%
left: 80%
color: darkred
- type: state-label
entity: vacuum.robot_odkurzajacy
attribute: total_cleaning_count
suffix: m
prefix: 'Ogólny Czas: '
style:
top: 25%
left: 81%
color: darkred
image: /local/moprobot.jpg
Pardon me, how is this code related to the issue? It does not contain sub-attributes.
Vaidas
February 8, 2023, 9:23pm
7
I made a workaround: created a new sensor based on existing, taking single value out of list of objects. New sensor can be than displayed in picture-elements card.
New sensor:
template:
- sensor:
- name: "Temperature min today"
unit_of_measurement: "°C"
state: >
{{ state_attr('weather.casa', 'forecast')[0]['templow'] }}
Picture-elements part:
- type: state-label
entity: sensor.temperature_min_today
style:
color: white
font-size: 15px
top: 70%
left: 20%