I have an Envisalink on my DSC alarm integrated to HA. From the attributes I made 2 sensors: Last armed by user and Last disarmed by user.
These give numbers as values (the user number on Envisalink). Can I change somehow my code to get defined names instead of the numbers as a value? I mean somehow define in the template sensor that:
1 means John
2 is Marie
3 is Jack
etc.
Thanks a lot! I’ll check it. I have an issue to solve. After a while the keypad sensor becomes cleared even nobody pressed anything on the Keypad, and it clears the attribute too:
Yes it would be OK. But somehow I’d like to show the last acting user whiich was identified instead of the cleared value. So something like the last history event which had defined user. E.g. if John disarmed 6 hours ago and the sensor went to “” 3 hours ago, then show John instead of “”.
So, after a day, it works perfectly! Thanks a lot again!
My new issue to somehow show only that sensor state which is the latest. E.g. it was disarmed 9 hours ago and then armed 4 hors ago, than show only the Armed_by sensor value but hide the Disarmed sensor.
Or armed 3 hours ago but disarmed 1 hour ago, than show only the Disarmed sensor state.
You can probably set up a new sensor that has a template like this:
{% if as_timestamp(sensordisarm) - as_timestamp(sensorarmed) >= 0 %}
latest action was disarmed, so insert your newly created disarmed sensor here.
{%- else -%}
latest action was armed, so insert your newly created armed sensor here.
{%- endif %}
Unfortunately the original solution doesn’t work well. After a HA restert the sensor shows empty value. In the history the last known is shown. Somehow the last not empty history state would be the solution,
That is what sensors do. They update when HA reboots.
If you want it to persist across a reboot then you need to save it somewhere and bring it back somehow after the reboot.