Increase or decrease thermostat target temperature

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
  - platform: state
    entity_id: weather.yweather
    from: 'sunny'
  - 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
  - service: climate.set_temperature
      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
      title: 'HA Climate'
      message: 'Thermostat set +1F due sunny conditions'

Possibly your sun condition is not right, doc suggests 2 entries, one for after sunrise, one for before sunset

After that I’d check each of your sensor values in the dev-tool to make sure they are in the wanted state…

I played with many conditions and triggering automation manually. The problem is in the action section.

Please, tell more details or link to it. I really want to know what is inside of this variables while it’s running (debugging).

Then to test your action, simply trigger your automation:

1 Like

lolouk44, thx. it was really useful.

here what I got

The right answer is

{{ states.climate['2gig_technologies_ct101_thermostat_iris_cooling_1'].attributes.temperature }}

1 Like

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: or  # 'when dark' condition: either after sunset or before sunrise
      - condition: sun
        after: sunset
      - condition: sun
        before: sunrise
1 Like

The way it is is fine - if you want the time period during the day - i.e., from sunrise to sunset. :slight_smile:

If you want when it’s dark, then you have to “or” two separate conditions.

Didn’t notice he was going for daytime. Assumed night… my bad.

Probably it is easier way

{{ is_state("sun.sun", "above_horizon") }}

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.

You’re right.

I didn’t post part of config that switch it back when it is goes out of cloudy, but anyways it risky config.