#How to pass information from sentence triggers?
1 messages · Page 1 of 1 (latest)
To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.
But I guess you're looking for the trigger variable:
https://www.home-assistant.io/docs/automation/templating#sentence
Thanks, this worked :)
I just did not understand trigger variables at all ^^'
alias: test Automation
description: ""
triggers:
- trigger: conversation
command:
- test {prozent} [Prozent|%]
conditions: []
actions:
- action: cover.set_cover_position
metadata: {}
data:
position: "{{ trigger.slots.prozent }}"
target:
entity_id: cover.rollo2_roller_2
mode: single
Wait. Is it possible to use alias with sentence triggers? Like:
alias: test Automation
description: ""
triggers:
- trigger: conversation
command:
- drücke {name}
conditions: []
actions:
- action: cover.set_cover_position
metadata: {}
data:
position: 12
target:
entity_id: "{{ trigger.slots.name }}"
mode: single
Sorry, should I open a new request for this?
Yeah, think that should work, only you would need to really say the entity ID which is nearly impossible. Also, there is no check on that entity existing etc. So yeah, it is valid but not useful.
Yeah, which is exactly why I asked if it's somehow possible to use aliases ^^'
To convert Glotze to switch.fernseher1 automatically for example
Help would be very welcome ^^'
I spend the whole day googling and found no solution :c
you can do this via a mapping in the template
simple example:
{% set map = {'foo': 'bar', 'blah': 'meh'} %}
{% set key = 'foo' %}
{{ map[key] }}
-> bar
You need to establish a mapping of all the possible names and translations to entity_id in a generic solution. An alternative is to use the name to derive the entity_id in some way
another simple example:
- action: cover.set_cover_position
metadata: {}
data:
position: 12
target:
entity_id: cover.{{ trigger.slots.name }}
I wish the jinja2 extension had a function to fetch entities by Assist alias. Shouldn't be too hard but then again I am no dev.