I have a schedule (schedule.garage_hvac), in it there is extra data that defines temperature. Using the Developer tools I can see the current schedule exposes that in its attributes.
What is the correct template syntax for that?
schedule.garage_hvac.temperature?
schedule.garage_hvac.attributes.temperature?
When I try to use it in an action, I get an error.
“Failed to perform the action climate.set_temperature. expected float for dictionary value @ data[‘temperature’]. Got None”
I feel like I am close but I can’t get it too not give me that error.
I tried using the float() filter, I tried .atributes.
Or is this an issue with the climate.set_temperature where it won’t evaluate templates?
First, the temperature value seems to require being in double quotes if a template. Other template examples don’t show this.
Second, needs the “states.” and “attributes.”. Again, some examples don’t show these, but some do.
It’s too bad the Script UI for temperature doesn’t allow entering a template into it directly, it forces to numbers only. Always have to hit the edit xaml.
Any single line template should always be surrounded by single or double quotes, but if you have quotes within the template make sure you use the opposite quotes.
some_key: "{{ states('sensor.sensor_name') }}"
If you’re using multi line templates then you don’t…
some_key: |
{{ states('sensor.sensor_name') }}
It is all documented and explained in the Template Documentation under Templates in YAML, but there is a lot there to get through. Once you get it though you get it.
Also if you’re going to post YAML to the forum please make sure it’s properly formatted as per this guide, otherwise it’s impossible to tell where you might have gotten it wrong.
And finally, the recommended way to do what you’re doing to access the attributes would be
thanks! I fixed the formatting, I was looking for “code” format and “preformat” didn’t seem like the same thing. But of course, the standard three single backslashes on their own lines works. Not sure why I didn’t try that.
So, the script UI for temperature won’t allow entering a template, but once you edit it in xaml and insert the template and then come back, it shows the template and then you can edit the template. Am I missing something to trigger entering a template in the first place?
That is correct, template editors do not display until there is a template to edit. Easiest way to do that is via the 3 dot menu in the upper left of any section and selecting ‘Edit in YAML’.
Also it’s YAML not XAML, that is a totally different beast.