#How to pass information from sentence triggers?

1 messages · Page 1 of 1 (latest)

clever niche
#

I have an automation that uses sentence triggers. The sentences are like:
"open blind by x%"
"set blind to x%"

How do I retrieve the x value for later use in the automation?

charred frostBOT
#

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.

serene glen
clever niche
#

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
clever niche
#

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?

serene glen
#

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.

clever niche
#

Yeah, which is exactly why I asked if it's somehow possible to use aliases ^^'

#

To convert Glotze to switch.fernseher1 automatically for example

clever niche
#

Help would be very welcome ^^'
I spend the whole day googling and found no solution :c

cinder fjord
#

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 }}
tawny temple
#

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.