Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95488

Help with templating (setting variables and some formatting)

$
0
0

@opaulzen wrote:

Hi all,

I’m struggling with templates (sort of new to that) right now.

What I’m trying to achieve:

- alias: 'Alarm Triggered'
  initial_state: true
  trigger:
    - platform: state
      entity_id: sensor.visonic_panel_alarm_status
    - platform: state
      entity_id: sensor.visonic_panel_trouble_status
  condition:
    condition: template
    value_template: "{{ trigger.to_state.state != 'None' }}"
  action:
    - service: notify.telegram_oliver
      data_template:
        message: " Alarm Status changed!
        
        Panel last event is {{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event') }}
        
        Alarm is last triggered by {{ state_attr( 'XXXX', 'friendly_name') }}"

Now I would like the XXXX in the last line to be filled by the following template value:

{{ state_attr('alarm_control_panel.visonic_alarm', 'Panel Last Event Data'['Entity']) }}

The above works, and actually gives me a string that refers to an entitiy (that is actually a valid binary sensor. Now i would like to have the friendly name of this sensor printed instead of the entity name (that doesnt make sense to me).

Can i set a variable somewhere before the data_template part? Or within?

Furthermore, I often see a notifier message beginning with a >. Why is that? I know it is used to break strings over multiple lines, by the if I just add a linebreak (or 2) it works as well).

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>