I’m trying to automate target temperature depending on sunny/cloudy conditions outside.
What I’m trying to to it is to get current temperature, add or subtract 1F and set new target temp. It doesn’t work. Please, point me in right direction. Set temperature as ‘number’ works fine.
- id: 'Set +1F when Cloudy outside'
alias: Set +1F when Cloudy outside
trigger:
- platform: state
entity_id: weather.yweather
from: 'sunny'
condition:
- condition: sun
after: sunrise
before: sunset
- condition: zone
entity_id: device_tracker.oneplus_3
zone: zone.home
- condition: zone
entity_id: device_tracker.404e3623b573
zone: zone.home
action:
- service: climate.set_temperature
data_template:
entity_id: climate.2gig_technologies_ct101_thermostat_iris_cooling_1
#temperature: "{{ states.climate.2gig_technologies_ct101_thermostat_iris_cooling_1.attributes.temperature | float + 1 }}"
#temperature: "{{ (default(states.climate.2gig_technologies_ct101_thermostat_iris_cooling_1.attributes.temperature | float + 1) | default('82')) }}"
temperature: '82'
- service: notify.NOTIFIER_GMAIL
data:
title: 'HA Climate'
message: 'Thermostat set +1F due sunny conditions'
FYI @lolouk44 is correct. That sun condition is wrong. The documents spell out the correct way to do that:
You are most likely only getting ‘after: sunset’.
condition:
condition: or # 'when dark' condition: either after sunset or before sunrise
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
I’m pretty sure this isn’t what you REALLY want to do.
Let’s say your thermostat is on 70… and it becomes “sunny”. Then it’ll set your thermostat to 70 + 1… or 71.
Cool… then it weather goes to “cloudy”. Then “rainy”. Then “cloudy”. Then “sunny” again… so it’ll set your thermostat to 71 + 1 … or 72. Then the clouds are sort of coming and going… so state goes from cloudy to sunny every 10 minutes for 3 hours, or, 18 times. Now your thermostat is set to 90.
Instead of basing the new temperature on the set temperature, what you probably want is a input_number entity that you can set like you normally would your thermostat. Then, when it’s “sunny”, you can perfom this same “action” using that input_number as your reference point instead of the thermostat itself.
You’ll want another automation that sets it back to the normal value when the state is anything other than “sunny”. And you’ll want a third automation that will set the thermostat any time you change the input_number.
And… probably more pieces too… but that’s at least a better start.
Related story: I once has a climate automation that was based on a temperature sensor. Basically, if a certain room was hotter than the thermostat though it was, set the thermostat even colder until it got there. I put a lot of thought into getting it just right and it worked wonderfully. Until the temperature sensor died and I didn’t know it. Home Assistant continued to show me the last obtained value, which was still too hot, the thermostat got set lower and lower and lower and, even though it was FRIGID in that room now, Home Assistant didn’t know the temperature had gone down, and so it just kept making it colder.