#Error "Template returned invalid entity id"

1 messages · Page 1 of 1 (latest)

fading tiger
#

I am attempting to create an automation using a dictionary of entities but it keeps failing with error "Template returned invalid entity id"



alias: Blinds
description: Set Blind Position
triggers:
  - trigger: conversation
    command:
      - (set|adjust) [the] blind [in the] {blind} [to] {percentage} percent
    id: setblinds
conditions: []
actions:
  - variables:
      blinds_map:
        livingroom: cover.living_room_blinds
        masterbedroom: cover.master_bedroom_blinds
        guest1: cover.guest_bedroom_1_blinds
        guest2: cover.guest_bedroom_2_blinds
        office: cover.office_blind
  - variables:
      blind_norm: "{{ trigger.slots.blind | lower | replace(' ', '') }}"
  - action: cover.set_cover_tilt_position
    data:
      tilt_position: "{{ trigger.slots.percentage }}"
    target:
      entity_id: "{{ blinds_map[blind] }}"
mode: single ```

Is this supported??
brisk breachBOT
#

@fading tiger 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.

austere seal
#

What is the variable blind?

fading tiger
#

from the sentence - expectation was it would take the word in my sentence, where "office" is {blind} in "adjust the blind in the office to 50 percent" as an example - then filter the blinds_map[blind] for the value.

#

i been trying to read on the templating and automations but not many examples of pulling a value from a dictionary to fill in the entity id

austere seal
#

I dont think it works this way. Is there any "variable" option fornconversqtion trigger?

wintry shore
#

You would use trigger.slots.blind (just like the variable object used for {percentage} three lines further down)...

Also, if you are going to go through the trouble of using another variable, blind_norm, to format the string, you need to use blind_norm to extract the entity ID from the dictionary blinds_map...

undone epoch
hexed prairie
#

Also need quotes around the entity id’s (the keys of the blinds_map dict)

#

Actually this being yaml so I’m wrong on that. Although it wouldn’t hurt.
Ignore me

fading tiger
#

originally i tried using the "trigger.slots.blind" but it was giving me an error "Error: UndefinedError: 'dict object' has no attribute 'slots'"

undone epoch
fading tiger
#

yes, testing in the GUI - the error is what i got in the trace

undone epoch
#

that doesn't work if you use trigger variables

#

as there is no trigger when you run the automation from the GUI

fading tiger
#

I modified:

blind_norm: "{{ blind | lower | replace(' ', '') }}"

back to

blind_norm: "{{ trigger.slots.blind | lower | replace(' ', '') }}"

as I had originally and that is the error I'm getting

undone epoch
#

you need to use the Assist dialog and send the command

#

or acutally use a voice command

#

did you try it like this?

#

or did you just press the RUN button?

fading tiger
#

I just hit run button

#

oh wow, that worked 🙁 - i been chasing this for almost 2 days

undone epoch
#

Think of it this way. If you press that RUN button, how should HA know which room to target and which percentage to use? You're not providing that info if you just press a button

fading tiger
#

i was curious about but didn't find anything documented around that - could be nice if that was documented somewhere

undone epoch
#

Not sure if it is documented somewhere, but what would you've expected then when you pressed the RUN button? Which blind should have been set to which percentage?

#

oh wait, it's documented here

#

Testing with complex triggers, conditions, and variables can be difficult. Note that using the Run actions button will skip all triggers and conditions, while Developer Tools can be used with or without checking conditions.

fading tiger
#

figures troubleshooting

#

just reading it now

#

thanks

#

for this

#

i was expecting it would do some mock data to test but i get it

fading tiger
#

weird when i do it through assist typing it in - works as expected but when i do it via voice get error:

not sure what channel to go with this

undone epoch
#

Was the automation triggered by the Voice command? Or did it use the built in command?

#

You can check on settings > voice if it maybe misunderstood your command

#

(click on the 3 dot button next to your voice pipeline and select debug)

fading tiger
#

well that is odd thing now if I type it works fine but not matching on voice although based on what assistant is getting it should:

#

i figured it out

#

sigh

#

i had "percent" - where the pipline comes back as "%"

#

adjusted my automation and all working now