Using boolean Climate automation

Hello everyone,

I am relatively new to Home Assistant. I was forced to find an alternative to controlling all of my Radio Thermostats when the company turned off the cloud service. Home Assistant has been a good replacement for making remote access to these devices possible.

I have created an automation that sets the thermostats to a specific temperature when occupied and another when set to away. My automation works as expected but I have one thing I would like to correct.

My two scripts are below. The first automation triggered by the occupied / away toggle like I mentioned works as expected. The one problem I would like to correct is when someone manually changes the thermostat set-point. I would like to toggle the Boolean back to the occupied state. I created a second script that achieves this but after the additional script was added I now get a toggle bounce. I have tried timers, delays turning off the opposing script and nothing seems to work.

Any help would be greatly appreciated.

Script#1

alias: "Automation: Set Away Shelter House"
description: Sets Shelter House HVAC temp depending on away toggle
trigger:
  - platform: state
    entity_id:
      - input_boolean.helper_shelter_house_away_toggle
    id: helper toggle change
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: trigger
        id:
          - helper toggle change
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"
          - condition: and
            conditions:
              - condition: device
                device_id: 162679ed904b75ff8a8d4e2529a24c20
                domain: climate
                entity_id: 8a2dcdc3e7448f9a7f0a0f001f81f462
                type: is_hvac_mode
                hvac_mode: heat
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 50
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 80
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: heat
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 68
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 70
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
mode: single

Script#2

alias: "Automation: Manual temperature change, reset toggle to OFF"
description: Reset away toggle to off after manual temperature adjustment
trigger:
  - platform: state
    entity_id:
      - climate.shelter_house
    id: manual temperature change
    attribute: temperature
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.helper_shelter_house_away_toggle
        state: "on"
      - condition: and
        conditions:
          - condition: trigger
            id:
              - manual temperature change
action:
  - service: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.helper_shelter_house_away_toggle
mode: single

Your 2 automatons appear to be performing as the code intends.
The home/away automation seems to assume the helper is synced to some presence logic. Your second automation seems to assume the presence logic can miss someone present at the location & you thus appear to be using this automation to fix that. As a consequence turning the helper on triggers your first automation. That seems to result in your “bounce”
That is providing my understanding is accurate. (I’m still pretty green)

1 Like

there are a few very odd things in your code. please see ### marked comments below:

alias: "Automation: Set Away Shelter House"
description: Sets Shelter House HVAC temp depending on away toggle
trigger:
  - platform: state
    entity_id:
      - input_boolean.helper_shelter_house_away_toggle
    id: helper toggle change

### the below "for" not necessary if you want it immediate
    for:
      hours: 0
      minutes: 0
      seconds: 0

condition:

### conditions are all "anded" together. so you don't need to add another "and".  especially since you only have 1 condition

  - condition: and

## what is the purpose of this trigger condition?  there's only one trigger, so it will always be this id.  
    conditions:
      - condition: trigger
        id:
          - helper toggle change


action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"

what is the purpose of this "and"?   conditions are always "anded".  but furthermore and "and" block  ands the conditions *in* it's blcok (you only have 1 below).  it doesn't "and" it with preceding ones... 
          - condition: and
            conditions:
              - condition: device
                device_id: 162679ed904b75ff8a8d4e2529a24c20
                domain: climate
                entity_id: 8a2dcdc3e7448f9a7f0a0f001f81f462
                type: is_hvac_mode
                hvac_mode: heat

        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 50
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 80
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: heat
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 68
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: and
            conditions:
              - condition: device
                device_id: ea273bc1bfb97263e3b9e095ceef6bf7
                domain: climate
                entity_id: fa9179e660fae1f7605cb33383183fd3
                type: is_hvac_mode
                hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            metadata: {}
            data:
              temperature: 70
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.shelter_house_hold
mode: single

also, you should really avoid using device_id’s. use entity_id with friendly names. like climate.shelter_house. not 8a2dcdc3e7448f9a7f0a0f001f81f462

lots of good reasons for this. outlined here:

here’s a somewhat cleaned up version of your first automation:

alias: "Automation: Set Away Shelter House"
description: Sets Shelter House HVAC temp depending on away toggle
trigger:
  - platform: state
    entity_id:
      - input_boolean.helper_shelter_house_away_toggle
    id: helper toggle change
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"
          - condition: device
            device_id: 162679ed904b75ff8a8d4e2529a24c20
            domain: climate
            entity_id: 8a2dcdc3e7448f9a7f0a0f001f81f462
            type: is_hvac_mode
            hvac_mode: heat
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 50
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "on"
            - condition: device
              device_id: ea273bc1bfb97263e3b9e095ceef6bf7
              domain: climate
              entity_id: fa9179e660fae1f7605cb33383183fd3
              type: is_hvac_mode
              hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 80
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: device
            device_id: ea273bc1bfb97263e3b9e095ceef6bf7
            domain: climate
            entity_id: fa9179e660fae1f7605cb33383183fd3
            type: is_hvac_mode
            hvac_mode: heat
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 68
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            target:
              entity_id: switch.shelter_house_hold
      - conditions:
          - condition: state
            entity_id: input_boolean.helper_shelter_house_away_toggle
            state: "off"
          - condition: device
            device_id: ea273bc1bfb97263e3b9e095ceef6bf7
            domain: climate
            entity_id: fa9179e660fae1f7605cb33383183fd3
            type: is_hvac_mode
            hvac_mode: cool
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 70
            target:
              entity_id: climate.shelter_house
          - service: switch.turn_on
            target:
              entity_id: switch.shelter_house_hold
mode: single

since i don’t have your device id’s, i can’t really test it… but do a compare with your s block by block and see how much tighter the code is. it went from 116 lines to 87

now… to actually fix your problem… i’d probably have a boolean that said “manual override mode” … because that’s what’s really happening.

but a surgical fix is this (see my ## comment below)

alias: "Automation: Manual temperature change, reset toggle to OFF"
description: Reset away toggle to off after manual temperature adjustment
trigger:
  - platform: state
    entity_id:
      - climate.shelter_house
    id: manual temperature change
    attribute: temperature
condition:
  - condition: state
    entity_id: input_boolean.helper_shelter_house_away_toggle
    state: "on"
action:
  - service: automation.turn_off
    data:
      stop_actions: true
    target:
      entity_id: automation.name_of_the_Automation_set_away_Shelter_house
  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.helper_shelter_house_away_toggle
    data: {}

## i don't think this is necessary... but just in case... try testing with and without it.
  - delay:
      seconds: 5
      
  - service: automation.turn_on
    target:
      entity_id: automation.name_of_the_Automation_set_away_Shelter_house
    data: {}
mode: single

you need to replace the automation name above with the correct one for the first automation you had.

Have you considered using the Generic Thermostat integration instead of an automation?

There’s also a thermostat dashboard card for manual control:

Thanks for your reply. Yes, I thought about a “manual override.” but that kind of defeats the purpose of the original Boolean. I will continue to use as it is for now. The operator will simply need to do an additional tap of the toggle to put it back in sync. Thanks for the advice on the device ID’s. I will make sure not to use them going forward.

take a look at the code i posted above. what i posted fixes your issue w/o a manual override. i was saying that i personally would do it with a manual override, but if you didn’t want that, then i’m giving you that code instead…

I actually did. I got the same results with your code. Tried with and without the delay.

bummer… do you want to give up? this has to be solvable. but may need to do a little tracing… unless someone else here spots the issue. but if you don’t want to bother… your call. but if you want to figure it out, i’d update the second automation to this:

alias: "Automation: Manual temperature change, reset toggle to OFF"
description: Reset away toggle to off after manual temperature adjustment
trigger:
  - platform: state
    entity_id:
      - climate.shelter_house
    id: manual temperature change
    attribute: temperature
condition:
  - condition: state
    entity_id: input_boolean.helper_shelter_house_away_toggle
    state: "on"
action:
  - service: automation.turn_off
    data:
      stop_actions: true
    target:
      entity_id: automation.name_of_the_Automation_set_away_Shelter_house


  - delay:
      seconds: 5
      

  - service: input_boolean.turn_off
    target:
      entity_id: input_boolean.helper_shelter_house_away_toggle
    data: {}

  - delay:
      seconds: 5
      
  - service: automation.turn_on
    target:
      entity_id: automation.name_of_the_Automation_set_away_Shelter_house
    data: {}
mode: single

notice i put a 5 second delay before and after the house_away_toggle boolean change. so do this, trigger the manual temperature change, then see when does the first automation bounce it back? does it do it immeidately, at 5 seconds, or at 10 seconds.

No, I’m not giving up. But I did decide to add the local calendar integration so that may change things up a little. I have a total of 13 thermostats between 5 buildings. This is a church campus with the Pastor and a handful of others that have access to this. I just want to make sure I have it working 100% before I push this new version. My current HA installation is running on my Synology NAS in a docker container. As you know that greatly limits what we could do with HA. I decided to spin up Proxmox on an old machine. Since I now have a DEV platform I can do some trial and error.

I have these thermostats grouped into 5 different areas. for each group I now have 3 automations and 2 scripts so it is getting a little complicated. Your previous suggestion about using the device ID’s is a good one, but it appears these ID numbers are generated by HA when I built my custom conditions. I do not see any way of changing these ID’s I could provide a flow chart if that would help in understanding.

After adding the calendar integration, I have it working as before. Still have the nuisance of not being able to toggle the Boolean after a manual temperature change.

i think you may have misunderstood me about the device id. we’re not saying to rename device id’s to friendly human readable names. you can’t do that. those device ids, as you said, are generated and fixed. however each device has one or more corresponding entities. those entities are the things you should be interacting with. and those entities are ones you can choose the name of.

and when you build your automations and scripts, refer to just the entity_id friendly name. do not use the device id.

not only does this make your code more readable, the system will autocomplete for you so it’s easier to program. and, if ever a device breaks and you have to replace it, you won’t need to update all of your code. you just set the entity_id to be what the old broken one was, and everything continues to work.

back to the bouncing of temperature control. if you get a moment, do the test i said above with the 2 different wait times and let’s see at what point the bounce happens…

I am doing as you suggest as far as the friendly names. The results in code I’m not sure I can do anything different… Below is a screen shot of the condition that is showing the numeric string for ID. Below that is the code generated when building the automation.

Running out of time this evening, But I will give your code another go tomorrow evening.


oh, i understand the confusion now.

don’t choose “device” when you choose the condition type. choose “state”

then do something like this:

for climate, i believe hvac_mode is reported as it’s primary state value, so that’s why i have just the state itself.