trust me, I am trying. And am, aamof. But this is not that simple as you say.
I am hoping to find a way to have the auto-entities card show the lightning strikes of the last hour.
I cant check right now, because no strikes are registered, but your template counts the strikes.
next to that, the format of the filter of the auto-entities card requires yet another different syntax. Have only made a few of these, relying on a simple state (as posted above) makes me want to seek help of the community…
I don’t think you can do what you want to do with auto-entities. It doesn’t appear as if you can match state object properties with this card. @thomasloven would know for certain if there is a way to match against last_updated property (which is not an attribute). I doubt it because they are datetime objects.
You may be able to make an automation that updates minutely and dynamically changes the entities inside a group. Then use auto-entities match group as a card.
Yes, feared as much on the last updated. But maybe the attribute publication_date could come to the rescue? compare that to now and have set of states built on that?
{% set km = states('input_number.lightning_strikes_near') %}
{{ states.geo_location|selectattr('attributes.source','eq','wwlln')
|selectattr('state','lessthan',km)|list}}
I’ll have a look at that, as said, theses are only my first auto-entities cards.
This all wouldn’t be necessary if the integration wwlln: would simply work as described of course. window and radius not really effective, and seems the UI integration only uses window, which doesn’t work (yet, dev’s are working on that)
I agree. Personally, I don’t know why the lightning strikes were added as separate sensors. I would expect these to be attributes which would allow easy templating.
While Thomas is adding templating (yeah) I had a look at my domains sensor, and that would translate to something like this:
{%- set t = as_timestamp(now()) - 60 * 60 %}
{%- for s in states.geo_location %}
{%- if s.entity_id.attributes.source == 'wwnnl' and s.last_updated != None and as_timestamp(s.last_updated) > t %}
{%- endif %}- {{s}}
{%- endfor %}
cant test it now, because no lightnings are around, but am not sure of the {{s}}.
Would that show the full entity, thuis building the list I require?
{%- if s.attributes.source == 'wwlln' and s.last_updated != None and as_timestamp(s.last_updated) > t %}
instead of
{%- if s.entity_id.attributes.source == 'wwllln' and s.last_updated != None and as_timestamp(s.last_updated) > t %}
making it
{%- set t = as_timestamp(now()) - 60 * 60 %}
{%- for s in states.geo_location %}
{%- if s.attributes.source == 'wwlln and s.last_updated != None and as_timestamp(s.last_updated) > t %}
{{ s.entity_id }}{{ ',' if not loop.last else ''}}{%- endif %}
{%- endfor %}
but only of the domain geo_location and source wwnnl. Which get created if and when lightning is registered. Currently they aren’t there, so no list is created.
not yet using it, but as said, hope to be able to use it somehow in the Lovelace frontend. Will use it with source usgs_earthquakes_feed also.
most likely use it for Map, because I need an entity list there. If I can get the Maps card to be templated, and then replace this:
marked your post as solution, it shows fine after the discussed edits above!
this is it:
{%- set t = as_timestamp(now()) - 60 * 60 %}
{%- for s in states.geo_location %}
{%- if s.attributes.source == 'wwlln' and s.last_updated != None and as_timestamp(s.last_updated) > t %}
{{ s.entity_id }}{{ ',' if not loop.last else ''}}{%- endif %}
{%- endfor %}
{% set hour = states('input_number.strikes_period')|float %}
{%- set t = as_timestamp(now()) - hour*(60 * 60) %}
{%- for s in states.geo_location %}
{%- if s.attributes.source == 'wwlln' and s.last_updated != None and as_timestamp(s.last_updated) > t %}
{{ s.entity_id }}{{ ',' if not loop.last else ''}}{%- endif %}
{%- endfor %}
to create an option to have an input_number in the front-end allow me to see the when most of the strikes happened.
first I tried it without the |float on hour, but then I realized even an input_number isnt a number, but a string…
what I hadn’t noticed before at all, is that all input_numbers have a state with a decimal number. Even if the minimum step is an int. And still are strings…
confusing.
secondly, and most importantly, it adds the , even after loop.last with makes the full template fail in the frontend.
somehow is doesnt see the last as last, because no matter what I enter in the else clause, is isnt displayed, instead a , is used.