@orcinus wrote:
I can’t, for the life of me, figure out what i’m doing wrong here, but i’m sure i’m missing something obvious…
When i try this test Jinja template in the Template tab:
{% set foo = states.geo_location %} {{ foo | map(attribute='name') | list }}
i get back the list of geo_location domain states as expected:
['M 3.4 - 1km SSW of Kasina, Croatia', 'M 4.6 - 4km WSW of Kasina, Croatia', 'M 5.4 - 3km SW of Kasina, Croatia']
But if i use it in an actual template sensor, i get an empty list:
[]
This happens even if i use the
entity_id: sensor.time
trick to ensure it’s getting updated.
Any ideas?PS: Code above is just an example i’m using for debugging purposes… What i’m actually trying to do is something like this:
{% set time = states.geo_location | map(attribute='attributes.time') | max %} {% set sensor = (sensors | selectattr('attributes.time','eq', time) | list)[0] %} {{state_attr(sensor.entity_id, "magnitude")}}
… i.e. get the latest earthquake from
usgs_earthquakes_feed
and use the magnitude as the template sensor value.PPS: Nothing useful in the logs, no errors.
Posts: 1
Participants: 1