nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.36k stars 121 forks source link

[feature request] {{open_sensors}} as friendly_name array #51

Closed samvanh closed 3 years ago

samvanh commented 3 years ago

Hi, As the name suggests, I propose an extra state attribute with the friendly names of the current {{open_sensors}} attribute. Use case: this way smart speakers can announce the reason for the alarm trigger (in case they don't like the notification component or to build bigger trigger scripts). Thanks

nielsfaber commented 3 years ago

If you want to create a script, then you can also get the friendly name from the entity properties. I mean states('binary_sensor.my_sensor') will give you all info of the sensor. Why do you think such properties should be published by Alarmo?

samvanh commented 3 years ago

I think the reporting of {{open_sensors}} as a friendly-name array would allow the creation of more powerful scripts than what is currently possible in the Alarmo -> Actions page.

My use case is: On alarm trigger -> script to play siren on smart speakers + then announce which sensor triggered the alarm. The script works very well but doesn't have easy access to the friendly name of the sensor that triggered the alarm. A workaround for me is to create a template sensor that translates the {{open_sensors}} array into the friendly names but it's not very elegant.

When I try to copy-paste my working script into the Alarmo -> Actions -> yaml editor, I cannot save because it's triggering some errors.

nielsfaber commented 3 years ago

IMO only the entity_id + state is relevant info for the trigger event. You can easily get all the details you want about the sensors by requesting the state of the entity. Please check out here: https://www.home-assistant.io/docs/configuration/templating/#states-examples

I'd rather put effort into improving the editor such that it will work with your smart speaker without external scripts.

samvanh commented 3 years ago

Ok. In that case, you can close this FR.

For whoever's interested, this is the script I use to ring a siren + announce which sensor triggered the alarm:

alias: Alarm Siren
sequence:
  - service: media_player.play_media
    data:
      media_content_type: sound
      media_content_id: amzn_sfx_scifi_alarm_04
      entity_id: media_player.echo_downstairs
    entity_id: media_player.echo_downstairs
  - service: notify.alexa_media_downstairs
    data:
      title: Intruder Alert!
      message: >
        Intruder Alert! 
        {% for open_sensor in state_attr("alarm_control_panel.alarmo", "open_sensors").keys() |list %}
          at {{ state_attr(open_sensor, 'friendly_name') }}
        {% endfor %}
      data:
        method: all
        type: announce
      target:
        - media_player.echo_downstairs
mode: single

(it kinda assumes that usually, only 1 sensor will trigger the alarm. In the case of 2 sensors it will say 'Intruder alert at sensor 1 at sensor 2')

samvanh commented 3 years ago

Just to add: Love your custom component! Don't let feature requests etc be anything else than a compliment for the already existing features! Keep up the great work

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days