{% set devices = integration_entities('browser_mod')|select('contains','browser_useragent')|list -%}
{% set ns= namespace(output = '') -%}
{% for dev in devices -%}
{% set out = dev.split('agent')[-2] -%}
{% if states(out) != 'unavailable' -%}
{% set ns.output = dev.split(".")[1].split("_browser")[-2] ~'/'~ states(out) ~ states[out].last_updated.strftime('(%d%b%H:%M)') ~ '; ' ~ ns.output -%}
{% endif -%}
{% endfor -%}
{{ ns.output|truncate }}
Itās not quite doing what you want, but you can adapt it. Iāve been fumbling my way towards logging how much time my HA is getting used and this was one (failed) step to recording the times currently logged-on users changed.
But can you be more precise as to what you mean by ānot workingā? That the popup doesnāt appear at all? How long does it work for after refreshing browser cache for example? If you use the browserās developerās tools, does it show any loading errors?
Maybe try removiing the custom:stack-in-card? Or trying a core card rather than custom:more-info-card? Then we can perhaps establish whether the problem is with the popup action itself, or just the way youāre configuring the content.
Not sure how to now use your code inside the javascript, since I donāt have access to integration_entitiesā¦but waitā¦now I know the browser_id, I should be able to poke at the states('sensor'+browser_id+'_useragent') or something like thatā¦
This gets you the user name using the same technique. But some bewares: more than one user might be logged on, hence the list output. Big problem is that it canāt always find a logged on user; when Iām playing around with template editor it gives a null after a while. Weird.
using: >
{% set devices = integration_entities('browser_mod')|select('contains','browser_useragent')|list -%}
{% set ns= namespace(output = '') -%}
{% for dev in devices -%}
{% set out = dev.split('agent')[-2] -%}
{% if states(out) != 'unavailable' -%}
{% set ns.output = dev.split(".")[1].split("_browser")[-2] ~'/'~ states(out) ~ states[out].last_updated.strftime('(%d%b%H:%M)') ~ '; ' ~ ns.output -%}
{% endif -%}
{% endfor -%}
{{ ns.output|truncate }}
What I really want to do is log to a csv file every time a user logs on or out (or times-out). I just canāt get any event to reliably trigger from a log on.