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

How to access entity name within automation?

$
0
0

@joernborup wrote:

Hi team

Need a bit of help - and sure for the solution, but also for where I should be able to ‘read me to the answer’, I find it hard to see the logic in the documentation. So where should I be able to find the answer for my question ? Like which attributes are accessible where (like in automation) and how to get to it ? I would like to master HASS ;-))

But now to the question.
I have many windows, and would like to know when they are opened.
I would like to have just one automation.
I have a ‘sonos_say’ script that controls a sonos speaker - this works fine.

Now, what I would like to do, is in the ‘message’ string, to reference the friendly name of the entity. But I do not succeed with this. The speaker reads out the ‘code’ instead of resolving to the friendly name.

I have tried with:
message: ‘{{states(sensor.friendly_name)}} Window has been opened’
message: “{{trigger.entity_id.friendly_name}} Window has been opened”

I would like to go with out ‘ “ for the code part, but the editor says no :wink:

So, what is the proper way of doing this ?

The code:

- id: '1574603766995'
  alias: Window opened
  description: ''
  trigger:
  - device_id: f7a55006ff8e442a8a145292edc71ffc
    domain: binary_sensor
    entity_id: binary_sensor.masterbedroom_window_detector_sensor_2
    platform: device
    type: opened
  condition: []
  action:
  - data:
      delay: 00:00:05
      message: "{{trigger.entity_id.friendly_name}} Window has been opened"
      sonos_entity: media_player.kitchen
      volume: 0.3
    service: script.sonos_say

Regards Jørn

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95468

Trending Articles



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