Alarmo open_sensor: templates

My template for alarmo have stopped working.
I had a senor to see which sensor trigged the alarm and got the friendly name of the sensor.
but now it just blank.

{% set result = namespace(sensors=[]) %}
{% for state in states.sensor
  | selectattr('attributes.device_class', 'defined')
  | selectattr('attributes.device_class', '==', 'open_sensors')
  | rejectattr('state', 'in', ['unavailable', 'unknown'])
  | selectattr('entity_id', 'search', 'friendly_name') %}
  {% set result.sensors = result.sensors %}
{% endfor %}
{{ result.sensors|join('\n') }}

Your template selects sensor entities whose device_class is “open_sensors” and whose entity_id contains the string “friendly_name”.

Do you actually have sensors whose entity_id contains the string “friendly_name”?

Go to Developer Tools > States and type device_class: open_sensors in the Attributes search field.


Post a screenshot of the reported results.

if I just filter on open_sensors I get this on alarmo entity.
under open_sensor I get binary_sensor.pannrum_person_occupancy
and I want the friendly name on that entity.
I use it in notification and automations.

That screenshot contains only one entity and it doesn’t even have a device_class attribute. The template you posted above can’t possibly find this entity.

You said the “template for alarmo have stopped working” which implies it used to work. So what changed in your system recently to may have caused the template to stop working?

The template you posted above, the one that allegedly used to work, isn’t designed to find the friendly_name of that binary_sensor.

It’s difficult to help you because you asked to fix a template that’s designed to find entities you don’t have. Then you asked to find something that the template is also not designed to find.

I don’t really know how it worked before I don’t know where found the code.

I made a new one that works for now.

you seem good at coding.
does it look good, or should I change something?

{%if not state_attr('alarm_control_panel.alarmo', 'open_sensors') == None %}
  {%set trigger = state_attr('alarm_control_panel.alarmo', 'open_sensors') | join %}
  {{state_attr( trigger , 'friendly_name')}}
  inget larm

What does it report when the value of open_sensors contains more than just one item?

for alarmo it works because alarmo just store the first sensor that triggers the alarm.
but I think I have to work whit my alarm some more until it’s finished.