6 m

A fan next to a windowHome Assistant is built with the idea to bring smart home products together from multiple brands. This works really great, but sometimes, things can get a little hard to make. My climate control is one of those things. Now that winter is fast approaching and it is getting colder everyday, it’s time to share my climate control with the World Wide Web.

A few months ago, I wrote an article about my fan and the beginning of my own built climate control. In this article, I talked about playing with the generic thermostat platform to gain more control over my fans and heaters, but there was one issue why I didn’t share my thoughts earlier. The generic thermostat platform within Home Assistant doesn’t support more than one mode per thermostat. So, a thermostat can only be used for heating or cooling, but not both. The temporary solution was two thermostats per room; one for heating and one for cooling, but that isn’t convenient. Luckily, I found a custom component which solves this issue.

I used multiple things within my climate control. Below is a list of integrations, devices, custom components and Lovelace cards that I used so you can follow along.

  • Two Philips Hue Motion Sensors; which has a temperature sensor on board
  • Template switches to get my existing radiator valves into a new virtual thermostat
  • An input boolean as a master switch for the climate control
  • The dual mode generic thermostat platform custom component
  • The Nervetattoo simple thermostat card for Lovelace

All the things I added as a custom component for this climate control are available via the Home Assistant Community Store (HACS). You can do it without, but I can really recommend you to install the community store, because it’s full of awesome custom components. Instructions how to install HACS can be found here.

If you already have a thermostat which combines the heat and cool modes, you can start at ‘Climate automations’.

Preparations

The dual mode generic thermostat works with two switches: one to toggle the heater and one to toggle the cooler. For my cooler, I am using input booleans which are allowed as toggle switches, but my smart radiator valves are another story. In order to get these smart valves into a new combined thermostat, I needed to create two template switches which are going to control the radiator thermostats. To be on the safe side, I created a service call for the ‘turn_on’ actions which set the hvac-mode to ‘heat’ and the temperature to 24 degrees celsius; the max for my thermostats is 25 degrees celsius. Pretty high, but it doesn’t matter since I am going to create my own generic thermostat. The template sensor for one of my smart valves looks as follows:

# Example configuration switch for existing thermostats
switch:
  - platform: template
    switches:
      lv_radiator:
        friendly_name: "Living room Radiator"
        value_template: "{{ is_state('climate.living_room_heater', 'heat') }}"
        turn_on:
          service: climate.set_temperature
          data:
            entity_id: climate.living_room_heater
            temperature: 24
            hvac_mode: heat
        turn_off:
          service: climate.turn_off
          data:
            entity_id: climate.living_room_heater

After doing this for the existing thermostats, you now have a toggle switch to set the thermostat to the preferred hvac-mode.

Dual mode generic thermostat

Now it’s time to install the dual mode generic thermostat platform. You can find more information about this platform on GitHub. If you want to install this platform without HACS, you will also find instructions how to do that on the same page. If you are going to install the dual mode generic thermostat through HACS, please add the following custom repository link to your Integrations within HACS:

https://github.com/zacs/ha-dualmodegeneric

A big thumbs up for Shandoosheri and zacs for building this fantastic custom component.

After installing and restarting Home Assistant, it’s time to create the configuration for the dual mode generic thermostat. It should be straight forward, but for your convenience, I put my configuration below as an example.

# Example configuration for dual mode generic thermostat
climate:
  - platform: dualmode_generic
    name: Living room thermostat
    heater: switch.lv_radiator
    cooler: input_boolean.living_room_fan
    target_sensor: sensor.lv_average_temperature
    min_temp: 15
    max_temp: 25
    cold_tolerance: 0.5
    hot_tolerance: 0.5
    initial_hvac_mode: "off"
    precision: 0.1

After another restart of Home Assistant, you now have one thermostat with a heat and cool mode.

Climate automations

Before I started to create automations, I created an input boolean called ‘Climate control’. I added this boolean as a condition to every climate automation. Using this input boolean, I can easily turn off all my climate automations and take back control over my thermostats. You can create this input boolean under configuration > Helpers within Home Assistant.

Now, the automations. Every house is different. So, the following examples are specifically for my apartment on the 10th floor. I will show of them anyway to give you some inspiration for your own climate control.

Example 1: Heat and cool off when leaving the house

When I leave my apartment, both thermostats in the living and bedroom will turn off.

- alias: Climate Control - Away mode on
  description: ''
  trigger:
  - entity_id: alarm_control_panel.barking_jane
    platform: state
    to: armed_away
  condition:
  - condition: state
    entity_id: input_boolean.climate_control
    state: 'on'
  action:
  - data: {}
    entity_id: all
    service: climate.turn_off
  mode: single

Example 2: Turn off thermostats, only while heating

Since the thermostats are combined for heating and cooling, you need to be careful when turning off the thermostats. In this example, the thermostats are turned off when I am going away or to bed, but also when the sun starts shining. In this situation, I only want the thermostat to be turned off when it’s heating.

- alias: Climate control - Heat off
  description: ''
  trigger:
  - entity_id: alarm_control_panel.barking_jane
    platform: state
    from: disarmed
  - entity_id: binary_sensor.sun_is_shining
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: input_boolean.climate_control
    state: 'on'
  - condition: template
    value_template: "{{ is_state(\"climate.living_room_thermostat\", \"heat\")\n \
      \ or is_state(\"climate.bedroom_thermostat\", \"heat\") }}"
  action:
  - data: {}
    entity_id: all
    service: climate.turn_off
  mode: single

Example 3: Turning on the heat when it is cold

In this example, the thermostat in the living room turns on when the inside and outside temperature reach a specific threshold, the sun is not shining, when I am home and not asleep and when the balcony door is closed.

- alias: Climate control - Living room heat on
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.lv_temperature
    below: '19'
  - platform: numeric_state
    entity_id: sensor.balcony_temperature
    below: '11.9'
  - entity_id: alarm_control_panel.barking_jane
    to: disarmed
    platform: state
  - entity_id: binary_sensor.sun_is_shining
    for: 00:05:00
    from: 'on'
    platform: state
    to: 'off'
  - platform: state
    entity_id: binary_sensor.lv_balcony_door
    from: 'on'
    to: 'off'
  condition:
  - condition: numeric_state
    entity_id: sensor.lv_temperature
    below: '19'
  - condition: numeric_state
    entity_id: sensor.balcony_temperature
    below: '11.9'
  - condition: state
    entity_id: alarm_control_panel.barking_jane
    state: disarmed
  - condition: state
    entity_id: input_boolean.climate_control
    state: 'on'
  - condition: state
    entity_id: binary_sensor.sun_is_shining
    state: 'off'
  - condition: state
    entity_id: binary_sensor.lv_balcony_door
    state: 'off'
  action:
  - data:
      entity_id: climate.living_room_thermostat
      hvac_mode: heat
    service: climate.set_hvac_mode
  mode: single

Example 4: Fans on when it is hot

In this last example, the fans will turn on when it’s hot inside and outside my house. The conditions in this automation are a lot less strict than in example 3, because I don’t have any shadow on the 10th floor.

  alias: Climate control - Living room fan on
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.lv_temperature
    above: '23.49'
  - platform: numeric_state
    entity_id: sensor.balcony_temperature
    above: '25.5'
  - entity_id: alarm_control_panel.barking_jane
    from: armed_away
    platform: state
  condition:
  - condition: numeric_state
    entity_id: sensor.lv_temperature
    above: '23.49'
  - condition: numeric_state
    entity_id: sensor.balcony_temperature
    above: '25.5'
  - condition: template
    value_template: '{{ not is_state("alarm_control_panel.barking_jane", "armed_away")
      }}'
  - condition: state
    entity_id: input_boolean.climate_control
    state: 'on'
  action:
  - data:
      entity_id: climate.living_room_thermostat
      hvac_mode: cool
    service: climate.set_hvac_mode
  mode: single

Nervetattoo simple thermostat card for Lovelace

Screenshot of thermostat Lovelace cardLastly, I put a card on my dashboard to control the thermostat and see all the necessary details. The default thermostat card doesn’t allow extra entities to be shown, so a friend of my found the card you see to the left. You can get this custom card through the Home Assistant Community Store (HACS) or via this repository on GitHub. Besides the temperature, I also placed the humidity sensor from my radiator valve and the door sensor on it to see all relevant information. The exact config from the card as I am using it, is shown below:

- type: horizontal-stack
  cards:
    - type: 'custom:simple-thermostat'
      entity: climate.living_room_thermostat
      sensors:
        - entity: sensor.lv_humidity
        - entity: sensor.lv_balkondeur
      step_layout: column
      name: Thermostaat
      label:
        temperature: Temperatuur
        state: Status
      control:
        hvac:
          heat: true
          cool: true

As you can see, I put the card on a horizontal stack card to make sure it fills the entire width of my smartphone display. I also translated the state and temperature to dutch (my native language). To translate it back to English, you just can delete the ‘label’ element.

That’s the basic version of my climate control. I could tell more about it, but since every house is different and we all prefer different climates, I didn’t think it would be useful. I hope you got some inspiration from my idea. If you are seeing room for improvement, please let me know. 😊