produce different results; the former = none & the latter is producing a valid date_time. I know the former is recommended and indeed the only one I can use in the code below which correctly lists all the entities I want to monitor (work-in-progress - I intended to go on and count recent users):
{%- set devices = states | map(attribute='entity_id') | map('device_id') | unique | reject('eq',None) | list %}
{%- set ns = namespace(entities = []) %}
{%- for device in devices %}
{%- set ids = device_attr(device, 'identifiers') | list | first | default %}
{%- if ids[0] == 'browser_mod' %}
{%- set this = 'sensor.'~ids[1]|lower~'_browser_user' %}
{{ states(this,'last_changed')}}
{%- set ns.entities = ns.entities + [this] %}
{%- endif %}
{%- endfor %}
{% set ents = ns.entities %}
Thanks again. Nearly there now, but I had to change that to
{%- set this = ('sensor.'~ids[1] | slugify~'_browser_user') %}
otherwise I just got an array of none’s.
Now all I need to do is some date filtering and counting.
As most of these sensors are for currently inactive users, is there an easy way of seeing the user name (ie state) of it when is was last something other that ‘unavailable’? I’ve read that it can be done with SQL sensors but that looks like it would need a SQL for each entity not something that can be processed in a loop.