A/C automation

Managed to successfully set up climate automations for my air conditions (running on a Sensibo).

Using template sensors to get the “inside” temperature (and humidity) from attributes of the A/C entity:

#A/C sensors
  - platform: template
    sensors:
      downstairs_temp:
        friendly_name: 'Downstairs temperature'
        unit_of_measurement: '°C'
        device_class: temperature
        value_template: "{{ state_attr('climate.master_bedroom_a_c', 'current_temperature') }}"
      downstairs_humidity:
        friendly_name: 'Downstairs humidity'
        unit_of_measurement: '%'
        device_class: humidity
        value_template: "{{ state_attr('climate.master_bedroom_a_c', 'current_humidity') }}"

Then set up a threshold binary sensor using those temperatures:

binary_sensor:
  - platform: threshold
    entity_id: sensor.downstairs_temp
    lower: 16
    upper: 24
    hysteresis: 0.0
    name: downstairs_temp_thres

Then automated turning on before bedtime (with temperature and someone-at-home conditions):

#Sensibo night automation - master bedroom
#Turn on at 6.45pm
- alias: 'Downstairs AC night on'
  trigger:
   - platform: state
     entity_id: binary_sensor.downstairs_temp_thres
     from: 'on'
     to: 'off'
  condition:
    condition: and
    conditions: 
      - condition: state
        entity_id: group.all_devices
        state: 'home'
      - condition: time
        after: '16:45:00'
        before: '06:00:00'
  action:
    - service: climate.turn_on
      entity_id: climate.master_bedroom_a_c
    - service: climate.set_temperature
      data:
        entity_id: climate.master_bedroom_a_c
        temperature: 22
    - service: climate.set_swing_mode
      data:
        entity_id: climate.master_bedroom_a_c
        swing_mode: fixedTop
    - service: climate.set_fan_mode
      data:
        entity_id: climate.master_bedroom_a_c
        fan_mode: auto

As well as “turn off” automation for temperature back in range:

#Turn on if out of range
- alias: 'Downstairs AC range off'
  trigger:
   - platform: state
     entity_id: binary_sensor.downstairs_temp_thres
     from: 'off'
     to: 'on'
     for:
       minutes: 30
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c

For everyone leaves the house (not tested yet):

#Turn on if no-one home
- alias: 'Downstairs AC absent off'
  trigger:
   - platform: state
     entity_id: group.all_devices
     from: 'home'
     to: 'not_home'
     for:
       minutes: 30
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c   

And turning of in the morning (not tested yet):

#Turn off at 6.00am
- alias: 'Downstairs AC morning'
  trigger:
    platform: time
    at: "06:00:00"
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c
3 Likes

@AussieByrd, this looks like something im searching for.
Could you tell me how you have set up your automation in your configuration.yaml. Which type of includes. I just get a lot of errors trying to copy / paste this (ofcourse modifying it with correct entity).

Hi Dan… I’ve had some issues as well (that I wasn’t aware of at the time I published the above). I seem to have them all sorted now.

My template sensors for reading temperature from the Sensbo A/C controller work fine (sensor.downstairs_temp), but I now use two threshold binary senors (with different ranges) for my “turn on” threshold and my “turn off” threshold (these have also been “tuned” by feedback from my wife :slight_smile:). So the following is now in my configuration.yaml:

binary_sensor:
  - platform: threshold
    entity_id: sensor.downstairs_temp
    lower: 19
    upper: 24
    hysteresis: 0.0
    name: downstairs_temp_thres_on

  - platform: threshold
    entity_id: sensor.downstairs_temp
    lower: 20.5
    upper: 22.5
    hysteresis: 0.0
    name: downstairs_temp_thres_off

I’ve also revised my automations—including correcting the on/off order for my threshold binary sensors (which I had around the wrong way). These are in my automations.yaml so would need slight reformatting for use directly in your configuration.yaml. Automations are as follows (I’ve added new ones too):

Turn on A/C at 6.45pm if someones home, temperature is outside of the 19-24C range, and A/C is currently off (also sets the vent to ‘long throw’, fan to ‘high’ and mode to heat or cool based on temperature):

- alias: downstairs_ac_on_at_645pm
  trigger:
    - platform: time
      at: '18:45:00'
  condition:
    condition: and
    conditions: 
      - condition: state
        entity_id: group.all_devices
        state: 'home'
      - condition: state
        entity_id: binary_sensor.downstairs_temp_thres_on
        state: 'off'
      - condition: state
        entity_id: climate.master_bedroom_a_c
        state: 'off'
  action:
    - service: climate.turn_on
      entity_id: climate.master_bedroom_a_c
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.master_bedroom_a_c
        data_template:
          hvac_mode: >
            {% if states('sensor.downstairs_temp')|float < 20 %} heat
            {% else %} cool {% endif %}
    - service: climate.set_temperature
      data:
        entity_id: climate.master_bedroom_a_c
        temperature: 22
    - service: climate.set_swing_mode
      data:
        entity_id: climate.master_bedroom_a_c
        swing_mode: fixedTop
    - service: climate.set_fan_mode
      data:
        entity_id: climate.master_bedroom_a_c
        fan_mode: high

Turn on the A/C after 6.45pm (but before 11.30pm—everyone should be asleep by then :slight_smile:) (everything else is the same as above):

- alias: downstairs_ac_on_after_645pm
  trigger:
    - platform: state
      entity_id: binary_sensor.downstairs_temp_thres_on
      from: 'on'
      to: 'off'
  condition:
    condition: and
    conditions: 
      - condition: state
        entity_id: group.all_devices
        state: 'home'
      - condition: time
        after: '18:45:00'
        before: '22:30:00'
      - condition: state
        entity_id: climate.master_bedroom_a_c
        state: 'off'
  action:
    - service: climate.turn_on
      entity_id: climate.master_bedroom_a_c
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.master_bedroom_a_c
        data_template:
          hvac_mode: >
            {% if states('sensor.downstairs_temp')|float < 20 %} heat
            {% else %} cool {% endif %}
    - service: climate.set_temperature
      data:
        entity_id: climate.master_bedroom_a_c
        temperature: 22
    - service: climate.set_swing_mode
      data:
        entity_id: climate.master_bedroom_a_c
        swing_mode: fixedTop
    - service: climate.set_fan_mode
      data:
        entity_id: climate.master_bedroom_a_c
        fan_mode: high

Turn A/C on at 5.30am (so I’m not freezing when I get up a 6am):

- alias: downstairs_ac_on_at_530am
  trigger:
    - platform: time
      at: '05:30:00'
  condition:
    condition: and
    conditions: 
      - condition: state
        entity_id: group.all_devices
        state: 'home'
      - condition: state
        entity_id: binary_sensor.downstairs_temp_thres_on
        state: 'off'
      - condition: state
        entity_id: climate.master_bedroom_a_c
        state: 'off'
  action:
    - service: climate.turn_on
      entity_id: climate.master_bedroom_a_c
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.master_bedroom_a_c
        data_template:
          hvac_mode: >
            {% if states('sensor.downstairs_temp')|float < 20 %} heat
            {% else %} cool {% endif %}
    - service: climate.set_temperature
      data:
        entity_id: climate.master_bedroom_a_c
        temperature: 22
    - service: climate.set_swing_mode
      data:
        entity_id: climate.master_bedroom_a_c
        swing_mode: fixedTop
    - service: climate.set_fan_mode
      data:
        entity_id: climate.master_bedroom_a_c
        fan_mode: auto

Turn the A/C off in the temperature gets into the “comfortable zone” ( 20.5-22.5C) (only if its not already off):

- alias: downstairs_ac_off_when_temp_22_23
  trigger:
    - platform: state
      entity_id: binary_sensor.downstairs_temp_thres_off
      from: 'off'
      to: 'on'
      for:
        minutes: 30
  condition:
    - condition: template
      value_template: '{{ states("climate.master_bedroom_a_c") != "off" }}'
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c

Turn the A/C off is everyone leaves:

- alias: downstairs_ac_off_when_absent
  trigger:
    - platform: state
      entity_id: group.all_devices
      from: 'home'
      to: 'not_home'
      for:
        minutes: 30
  condition:
    - condition: template
      value_template: '{{ states("climate.master_bedroom_a_c") != "off" }}'
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c

Turn the A/C off at 11.30pm:

- alias: downstairs_ac_off_at_1030pm
  trigger:
    - platform: time
      at: "22:30:00"
  condition:
    - condition: template
      value_template: '{{ states("climate.master_bedroom_a_c") != "off" }}'
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c

And at 7.15am:

- alias: downstairs_ac_off_at_745am
  trigger:
    - platform: time
      at: "07:15:00"
  condition:
    - condition: template
      value_template: '{{ states("climate.master_bedroom_a_c") != "off" }}'
  action:
    - service: climate.turn_off
      entity_id: climate.master_bedroom_a_c

Hope this helps!

3 Likes

If you let me know what you’re trying to get automated (and post your current attempts) I might be able to help identify where your issues are too—then I can get my teacher/nerd voice on :nerd_face:

For starters I just want a simple automation turning on AC if its cold, and turning it off when temperature is high enough.

I have this in my configuration.yaml:

automation: !include_dir_merge_list automation
binary_sensor: !include_dir_merge_list binary_sensor.yaml
sensor: !include_dir_merge_list sensor.yaml

I have this in sensor.yaml:

#A/C sensors
  - platform: template
    sensors:
      stue_temp:
        friendly_name: 'Stuetemperatur'
        unit_of_measurement: '°C'
        device_class: temperature
        value_template: "{{ state_attr('climate.varmepumpe', 'current_temperature') }}"

I have this in binary_sensor.yaml:

  - platform: threshold
    entity_id: sensor.stue_temp
    lower: 5
    upper: 21
    hysteresis: 0.0
    name: stue_temp_thres_on

  - platform: threshold
    entity_id: sensor.stue_temp
    lower: 21.1
    upper: 40
    hysteresis: 0.0
    name: stue_temp_thres_off

And I have this in /automation/varmepumpe.yaml:

        ##########################################################
        ## Varmepumpe
        ##########################################################

#Sensibo night automation - master bedroom
#Turn on at 6.45pm
- alias: 'Varmepumpe på'
  
  trigger:
   - platform: state
     entity_id: binary_sensor.stue_temp_thres_on
     from: 'off'
     to: 'to'
     
  condition:
    - condition: state
      entity_id: input_boolean.gaar_hjemmefra
      state: 'off'
#    - condition: state
#      entity_id: input_boolean.kjorer_hjemmefra
#      state: 'off'
    - condition: state
      entity_id: input_boolean.godnatt
      state: 'off'
        
  action:
    - service: climate.turn_on
      entity_id: climate.varmepumpe
    - service: climate.set_temperature
      data:
        entity_id: climate.varmepumpe
        temperature: 23
    - delay: '00:00:10'
    - service: climate.set_fan_mode
      data:
        entity_id: climate.varmepumpe
        fan_mode: auto
    - delay: '00:00:10'
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.varmepumpe
        hvac_mode: heat
    - delay: '00:00:10'


#Turn off if out of range
- alias: 'Downstairs AC range off'
  trigger:
   - platform: state
     entity_id: binary_sensor.stue_temp_thres_off
     from: 'off'
     to: 'on'
     for:
       minutes: 5
  action:
    - service: climate.turn_off
      entity_id: climate.varmepumpe

I am not seeing any sensor (sensor.stue_temp or binary_sensor.stue_temp…) Not sure I got this correct?

I think perhaps I solved it using the following.

#         ##########################################################
#         ## Varmepumpe
#         ##########################################################

# Sett boolean "Varmepumpe kaldt" til på - som betyr at det er kaldt og at varmepumpa skal skrues på


- alias: Skru på boolean varmepumpe kaldt

  trigger:
    - platform: numeric_state
      entity_id: sensor.stue_temp
      below: 21.0
      for: '00:10:00'

  action:
    - service: homeassistant.turn_on
      entity_id: input_boolean.varmepumpe_kaldt
    - service: homeassistant.turn_off
      entity_id: input_boolean.varmepumpe_varmt

     
# Sett boolean "Varmepumpe varmt" til på - som betyr at det er varmt og at varmepumpa skal skrues av

- alias: Skru på boolean varmepumpe varmt

  trigger:
    - platform: numeric_state
      entity_id: sensor.stue_temp
      above: 21.1
      for: '00:10:00'

  action:
    - service: homeassistant.turn_on
      entity_id: input_boolean.varmepumpe_varmt
    - service: homeassistant.turn_off
      entity_id: input_boolean.varmepumpe_kaldt

# Skru på varmepumpe når kaldt

- alias: Skru på varmepumpe når kaldt

  trigger:
    - platform: state
      entity_id: input_boolean.varmepumpe_kaldt
      from: 'off'
      to: 'on'

  condition:
    - condition: state
      entity_id: input_boolean.gaar_hjemmefra
      state: 'off'
    - condition: state
      entity_id: input_boolean.godnatt
      state: 'off'
    - condition: state
      entity_id: binary_sensor.sensor_inngangsdor
      state: 'off'
    - condition: state
      entity_id: binary_sensor.sensor_terrassesdor
      state: 'off'

  action:
    - service: climate.turn_on
      entity_id: climate.varmepumpe
    - delay: '00:00:10'
    - service: climate.set_temperature
      data:
        entity_id: climate.varmepumpe
        temperature: 23
    - delay: '00:00:10'
    - service: climate.set_fan_mode
      data:
        entity_id: climate.varmepumpe
        fan_mode: auto
    - delay: '00:00:10'
    - service: climate.set_hvac_mode
      data:
        entity_id: climate.varmepumpe
        hvac_mode: heat

# Skru av varmepumpe når varmt

- alias: Skru av varmepumpe når varmt

  trigger:
    - platform: state
      entity_id: input_boolean.varmepumpe_varmt
      from: 'off'
      to: 'on'
    - platform: state
      entity_id: binary_sensor.sensor_terrassesdor
      from: 'off'
      to: 'on'
      for: '00:03:00'
    - platform: state
      entity_id: binary_sensor.sensor_inngangsdor
      from: 'off'
      to: 'on'
      for: '00:03:00'

  condition:
    - condition: state
      entity_id: climate.varmepumpe
      state: 'heat'

  action:
    - service: climate.turn_off
      entity_id: climate.varmepumpe

Glad you got it sorted :slight_smile:

Here is my A/C automation code:

- id: living_ac_hot_on
  alias: Living AC Hot On
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.living_temperature
    above: 31.8
    for: "00:00:05"
  condition:
    - condition: state
      entity_id: group.sensor_kitchen_door
      state: 'off'
    - condition: state
      entity_id: group.sensor_living_door
      state: 'off'
  action:
    service: climate.turn_on
    entity_id:
      - climate.living_ac
      - climate.kitchen_ac
- id: living_ac_cold_off
  alias: Living AC Cold Off
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.living_temperature
    below: 29
  action:
    service: climate.turn_off
    entity_id: 
      - climate.living_ac
      - climate.kitchen_ac
- id: luke_ac_hot_on
  alias: Luke AC Hot On
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.luke_temperature
    above: 31.6
    for: "00:00:05"
  condition:
    - condition: state
      entity_id: group.sensor_kids_windows
      state: 'off'
  action:
    service: climate.turn_on
    entity_id: climate.luke_ac
- id: luke_ac_cold_off
  alias: Luke AC Cold Off
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.luke_temperature
    below: 29
  action:
    service: climate.turn_off
    entity_id: climate.luke_ac
- id: noa_ac_hot_on
  alias: Noa AC Hot On
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.noa_temperature
    above: 31.6
    for: "00:00:05"
  condition:
    - condition: state
      entity_id: group.sensor_kids_windows
      state: 'off'
  action:
    service: climate.turn_on
    entity_id: climate.noa_ac
- id: noa_ac_cold_off
  alias: Noa AC Cold Off
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.noa_temperature
    below: 29
  action:
    service: climate.turn_off
    entity_id: climate.noa_ac
- id: master_ac_hot_on
  alias: Master AC Hot On
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.master_temperature
    above: 31.8
    for: "00:00:05"
  condition:
    - condition: state
      entity_id: group.sensor_master_door
      state: 'off'
  action:
    service: climate.turn_on
    entity_id: climate.master_ac
- id: master_ac_cold_off
  alias: Master AC Cold Off
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.master_temperature
    below: 29.5
  action:
    service: climate.turn_off
    entity_id: climate.master_ac
- id: electric_open_ac_off
  alias: Electric door AC off
  initial_state: true
  trigger:
    platform: state
    entity_id: binary_sensor.electric_door
    from: "off"
    to: "on"
  action:
    service: climate.turn_off
    entity_id: climate.electric_ac

Hi Ced

I notice that you seem to have repeated a condition statement for your living_ac_hot_on automation—that is:

  condition:
    - condition: state
      entity_id: group.sensor_kitchen_door
      state: 'off'
    - condition: state
      entity_id:  group.sensor_kitchen_door
      state: 'off'

There also seems to be a double space in front of the second group.sensor_kitchen_door which may cause some issues.

Regards,
Ben.

1 Like

Totally right on the money here Ben. Cheers!
Just corrected this. The second condition was meant for a different group of doors & windows.
Automations in yaml are still a tad painful with documentation not always up to date and different syntax for trigger, conditions and actions. Good to see this seems to be a priority amongst more able programmers than me…
I’m still refining these automations along with others. Focusing on notifications at mo.

Hello Thank you for posting this! I’m a bit new to HA and got a Sensibo, I fillowed the steps to get the API key and add the two lines into the config file but I’m not sure what to do next. Can I use the HA thermostat card to control Sensibo?
Thank you

You definitely can—that’s kinda what I’m doing:


All you need to do is add a card with the Sensibo climate.xxxxx entity. You can do this in a thermostat card if you like the dial layout. Personally, I have two climate entities in plain entity card. Its more compact, and I just use the pop-up card (above) for fine control.

Thank you for your reply, your screenshot is exactly what I am after!. My sensibo entity appears as “binary_sensor.updater”, but when I add that entity to either an entity card or a thermostat card I get the message “Entity not available: climate.binary_sensor.updater” I tried removing and adding the “climate.” and the “.updater” but haven’t been able to see it work propperly. I added this into the config file:

climate:
- platform: sensibo
api_key: <API Key from Sensibo website>

Is there anything I’m missing?
Thank you

You may have some issues with your yaml indents if it looks exactly like that. Should be:

climate:
  - platform: sensibo
    api_key: YOUR_API_KEY

When you look is at ‘States’ (under ‘Developer Tools’ in the HA interface) can you find a climate entity (it should have a name based on how you named it in the Sensibo app/web interface)?

Hello, thank yo so much for your replies, here is a sc of my config file, states and logs
I’m at my wits’ end with this

Try it without the single quotes around your API key.

Thank you works perfectly now! I kept trying different things and “restarting” but only after I shut down and turned on again that it fully worked.
Thank you for your help and patience.

No worries. Enjoy! :+1:

  - alias: Oprire AC
    trigger:
     platform: template
     value_template: "{{ states('sensor.time') == (state_attr('input_datetime.oprire_ac', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
    action:
    - service: climate.turn_off
      entity_id: climate.gree_ac

  - alias: Pornire AC
    trigger:
     platform: template
     value_template: "{{ states('sensor.time') == (state_attr('input_datetime.pornire_ac', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
    action:
    - service: climate.turn_on
      entity_id: climate.gree_ac
    - service: climate.set_hvac_mode  
      data:
       entity_id: climate.gree_ac
       hvac_mode: cool
    - service: climate.set_temperature
      data:
       entity_id: climate.gree_ac
       temperature: 24
    - service: climate.set_swing_mode
      data:
       entity_id: climate.gree.ac
       swing: Fixed in the middle-low possition
    - service: climate.set_fan_mode
      data:
       entity_id: climate.gree_ac
       fan_mode: medium

I see that you are using a Gree A/C unit. I am curious as to what type of HA integration you are using to control it? I have a Lennox mini-split which I believe is the same or similar to the Gree.
thanks