I need some assistance from the forum, please. I have a Nest thermostat, and I am trying to write a couple scripts that are activated by a button. Neither are working, and I am sure it’s my code.
The first script is supposed to look to see if I am heating or cooling the house, and then adjust the target temperature by 2 degrees (higher if heating, lower if cooling). I am trying to do this by comparing my house temperature to the outside temperature. I could use the hvac_mode, but if that is set to ‘heat-cool’, I may not know what’s really happening.
My second script is supposed to poll the current temperature and set that value to the target temperature. The idea being that i have become to cold (or hot), and just stop where it is.
Neither of my scripts are working and I can’t figure out why. I am hoping someone has done this before and has some suggestions. I am rather new to this, so any and all help is greatly appreciated!
Button Code:
show_name: true
show_icon: true
type: button
tap_action:
action: call-service
service: script.turn_on
target:
entity_id: script.climate_adjust
data:
climate_id: climate.upstairs
entity: script.climate_adjust
name: Nudge Temp
hold_action:
action: call-service
service: script.turn_on
target:
entity_id: script.climate_hold
data:
climate_id: climate.upstairs
The two scripts:
climate_adjust:
alias: Climate Adjust
sequence:
- variables:
target_temp: "{{ state_attr('{{ climate_id }}','target_temperature') | float(0) }}"
current_mode: "{{ state_attr('{{ climate_id }}','hvac_mode')}}"
adjustment: 2
- if:
- condition: weather.home.attribute.temperature > '{{ target_temp }}'
then:
- variables:
adjustment: -2
- service: climate.set_temperature
data:
temperature: '{{ target_temp }} + {{ adjustment }}'
hvac_mode: '{{ current_mode }}'
target:
entity_id: '{{ climate_id }}'
- service: climate.turn_on
data: {}
target:
entity_id: '{{ climate_id }}'
climate_hold:
alias: Climate Hold
sequence:
- variables:
current_temp: "{{ state_attr('{{ climate_id }}','current_temperature') | float(0) }}"
current_mode: "{{ state_attr('{{ climate_id }}','hvac_mode')}}"
- service: climate.set_temperature
data:
temperature: '{{ current_temp }}'
hvac_mode: '{{ current_mode }}'
target:
entity_id: '{{ climate_id }}'
- service: climate.turn_on
data: {}
target:
entity_id: '{{ climate_id }}'