itnassol
(Andrew)
February 11, 2024, 8:35am
1
A while ago I created an automation using the trigger.slots method and it works well, I am trying to do a similar but much simpler thing and it’s just not firing, any tips would be great. thanks.
I have tried…
service: input_number.set_value
metadata: {}
data:
value: {{ (trigger.slots.temp) }}
target:
entity_id: input_number.dro_max_temp
service: input_number.set_value
metadata: {}
data:
value: {{ trigger.slots.temp }}
target:
entity_id: input_number.dro_max_temp
and
service: input_number.set_value
metadata: {}
data:
value: { trigger.slots.temp }
target:
entity_id: input_number.dro_max_temp
koying
(Chris B)
February 11, 2024, 12:45pm
2
The trigger
variable is only defined in automations.
Assuming you are actually using automations, here, and that you are not just “running” the automation manually, which doesn’t define the trigger variable, please show the full automation(s).
itnassol
(Andrew)
February 11, 2024, 5:02pm
3
Hi, yes it is part of a automation, here is the complete thing.
alias: Speech Testing
description: ""
trigger:
- platform: conversation
command:
- Set Dining room temperature to {temp}
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value: {{ trigger.slots.temp }}
target:
entity_id: input_number.dro_max_temp
mode: single
As I said I have used something similar before, and actually a lot more complex (See below) and works beautifully, I am obviously missing something.
alias: Where is anyone
description: ""
trigger:
- platform: conversation
command:
- Where is {name}
condition: []
action:
- service: media_player.play_media
target:
entity_id: media_player.office_display
data:
media_content_id: >-
media-source://tts/cloud?message={{ states('sensor.' ~
trigger.slots.name | lower | replace('?', '') ~ 'cl')
}}.&language=en-IE&gender=female
media_content_type: provider
metadata:
title: Who is where.
thumbnail: https://brands.home-assistant.io/_/cloud/logo.png
media_class: app
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://tts
- media_content_type: provider
media_content_id: >-
media-source://tts/cloud?message={{ states('sensor.' ~
trigger.slots.name | lower | replace('?', '') ~ 'cl')
}}.&language=en-IE&gender=female
mode: single
Thanks
koying
(Chris B)
February 11, 2024, 5:06pm
4
You say it’s not firing, right?
So I guess the command is just not recognized. What does the assistant debug tells you?
itnassol
(Andrew)
February 11, 2024, 5:28pm
5
It is recognising the speech no problem, it seem to be something to do with the value.
I have tried this…
alias: Speech Testing
description: ""
trigger:
- platform: conversation
command:
- Set Dining room temperature to {temp}
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value: {{trigger.slots.temp|float}}
target:
entity_id: input_number.dro_max_temp
mode: single
And am still getting this error.
expected float for dictionary value @ data[‘value’]
itnassol
(Andrew)
February 11, 2024, 5:38pm
6
I think this might a be a limitation of the input number helper.
In my other automation I can add the variable in the UI, as below…
And then it is in the YAML
data:
media_content_id: >-
media-source://tts/cloud?message={{ states('sensor.' ~ trigger.slots.name |
lower | replace('?', '') ~ 'cl') }}.&language=en-IE&gender=female
In the input number if try to add it to the UI it just wont let me…
It will only let me enter a number…
If I add it in the YAML,
alias: Speech Testing
description: ""
trigger:
- platform: conversation
command:
- Set Dining room temperature to {temp}
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value: {{trigger.slots.temp|float}}
target:
entity_id: input_number.dro_max_temp
mode: single
Save it and go back to the YAML it has changed it to this…
alias: Speech Testing
description: ""
trigger:
- platform: conversation
command:
- Set Dining room temperature to {temp}
condition: []
action:
- service: input_number.set_value
metadata: {}
data:
value:
"[object Object]": null
target:
entity_id: input_number.dro_max_temp
mode: single
koying
(Chris B)
February 11, 2024, 6:03pm
7
Ah, jinja templates must always be enclosed with quotes. YAML continuation works as well, as in your working example.
itnassol
(Andrew)
February 12, 2024, 7:53am
8
Chris, Thank you…
I didn’t know that bit you’ve been a massive help.