Markus99
(Mark)
January 5, 2021, 1:22am
1
service_template: "script.set_hvac_{{states('climate.4055_front')}}_temp"
data_template:
hvac: climate.4055_front
temp: >-
{% if is_state('climate.4055_front','cool')
%}{{states('input_number.cool_hold_temp')|int}} {% else
%}{{states('input_number.heat_hold_temp')|int}} {% endif %}
Getting this error:
Failed to call service /null. expected str for dictionary value @ data[‘service’]. Got None
I feel like this was working previously… Currently on .118.5
finity
January 5, 2021, 1:26am
2
try this?:
service: script.set_hvac_{{states('climate.4055_front')}}_temp
data:
hvac: climate.4055_front
temp: >-
{% if is_state('climate.4055_front','cool')%}
{{states('input_number.cool_hold_temp')|int}}
{% else %}
{{states('input_number.heat_hold_temp')|int}}
{% endif %}
Markus99
(Mark)
January 5, 2021, 1:29am
3
TY for the quick response, unfortunately still the same error… Tried this as well:
service_template: >-
script.set_hvac_{{states('climate.4055_front')}}_temp
data:
hvac: climate.4055_front
temp: >-
{% if is_state('climate.4055_front','cool')%}
{{states('input_number.cool_hold_temp')|int}}
{% else %}
{{states('input_number.heat_hold_temp')|int}}
{% endif %}
finity
January 5, 2021, 1:46am
4
Hmmm…I’ve got one more thing to try (courtesy of petro in another thead):
service: script.set_hvac_{{states('climate.4055_front') ~ '\x00'}}_temp
I believe from his explanation that it should forcfe the template to return a string. Otherwise with the new template engine it will automatically return an int.
Hope it works.
Markus99
(Mark)
January 5, 2021, 3:12am
5
I’m on my phone now but I’ll have to try that when I get back to my PC. Thank you!
I think I remember reading a prior thread a few weeks back that the templating engine was going to mess with some of these default return types… Maybe they need to add a | str suffix for this…
finity
January 10, 2021, 2:04am
6
any word on whether my last suggestion worked?
Markus99
(Mark)
January 10, 2021, 5:30am
7
Unfortunately I haven’t had time to try it. I went with a script to do it and just call that in the automation, which is working fortunately.
jazzyisj
(Jason)
January 10, 2021, 5:45am
8
finity:
~ '\x00'
I haven’t seen this yet. Look interesting, will have to look into it to see how it works.
I think in this you could also make a template sensor for the climate set temp. States are still always strings right?
sensor:
- platform: template
sensors:
hvac_set_temp:
value_template: >
{{ states('input_number.cool_hold_temp') is_state('climate.4055_front','cool')
else states('input_number.heat_hold_temp') }}
You can then use the state of that sensor value in the service call and it will be a string as expected by the component.
service_template: "script.set_hvac_{{states('climate.4055_front')}}_temp"
data_template:
hvac: climate.4055_front
temp: "{{ states('sensor.hvac_set_temp') }}"