How to only change "target_temp_low"?

I’m using an automation to change my thermostats low setting based on the daily high temp.
Problem is I have to also send a target_temp_high in order for the command to work and i often adjust the high temp manually to turn on the a/c in the evenings.
Is there a way to not write a new target_temp_high or grab the current high_temp and use that?

It would be much easier for people to give you advise if you showed us the code you’re currently using.

{“entity_id”:“climate.home”,“target_temp_high”:26,“target_temp_low”:18}

Maybe a data_template in the automation service call using the state_attr helper would work?

automation:
  action:
    service: climate.set_temperature
      data_template:
        entity_id: climate.home
        target_temp_low: 18
        target_temp_high: "{{ state_attr('climate.home', 'target_temp_high') }}"

This will use the thermostat’s current high temperature value at the time the action is run. Not sure if the format/syntax is perfect, but that’s the idea.

How the parameters are accepted really depends on the component, they are implemented in different ways.

2 Likes

I think that is close but I got the following error
Call-service API error. Error Message: expected float for dictionary value @ data['target_temp_high']
I’m good enough with JSON to know if that is being cause by formatting or if it will only accept a number

I believe that means it wasn’t happy about encountering a template where it expected to find a floating point number.

I think you are right, the state attribute is probably a string. @Picnic try this one, which will convert the value to a float:

"{{ state_attr('climate.home', 'target_temp_high') | float }}"

hmm still getting the float error.

{ “target_temp_high”: “{{ state_attr(‘climate.home’, ‘target_temp_high’) | float }}”,
“target_temp_low”: 18 }

"Call-service API error. Error Message: expected float for dictionary value @ data['target_temp_high']"

I’ll say it again, it’s expecting you to provide a number (float) but you’re providing it a template. You’re assuming that the option supports a template and, based on the error message, that’s not likely.

You can prove it to yourself by simplifying the template. Let’s say you want the value to be 23.

We know this will work:

target_temp_high: 23

Now let’s see if it accepts it in template form. If you try this:

target_temp_high: "{{23}}"

my crystal ball says it won’t work.

You asked for an automation (YAML), yet you are pasting JSON that would be used with the developer service calls. I wouldn’t expect the template code to work in that case. Have you tried the automation yet?

I’ve come up with a different way of getting the result i’m looking for.
If the daily high temp is above a certain temperature I set the mode of the Thermostat to ‘cool’.
This way I don’t have to worry about sending any numbers and it won’t overwrite any manual changes I’ve made to the setpoint.