5 minutes

A fan next to a windowLiving on the 10th floor is beautiful. It also means no shadows at all. So, if it is a nice and sunny day, you will be fright by the sunlight in no time. Especially when your only balcony, like mine, is on the south side of the building. So, I designed my own climate control system in Home Assistant to prevent my house, my dog and myself from overheating.

First, let me tell you which devices I use in my climate system. I made it for my bedroom and the living room. In both rooms, I’ve got a Philips Hue motion sensor, which has a built-in temperature sensor. In my bedroom, I have a fan with an air-cooling mode and in my living room, I have just an order nary tower fan. The fans aren’t new or smart, but both can be controlled with an infrared remote. So, I used a universal smart remote from Broadlink to control these fans. I’m sending the commands through IFTTT, since I still don’t get the Broadlink remote service to work. However, since IFTTT announced their new strategy, I am planning to connect my remotes directly to Home Assistant. Please read this article for my opinion about the recently announced plans of IFTTT.

First, I created an Input Boolean. I named it ‘Climate Control’. This way, I will still be able to turn off all my climate related automations at once and overwrite the system. I’m not expecting a handmade climate control to be perfect. I also created a corresponding switch for Apple’s Home Kit app in my configuration file.

# Switche example
switch:
  - platform: template
    switches:
      climate_control:
        friendly_name: "Climate Control"
        value_template: "{{ is_state('input_boolean.climate_control', 'on') }}"
        turn_on:
          service: input_boolean.turn_on
          data:
            entity_id: input_boolean.climate_control
        turn_off:
          service: input_boolean.turn_off
          data:
            entity_id: input_boolean.climate_control

Next, I had to determine when the fans have to turn on and off. If they turn on at a low temperature, it will cost me money in energy bills. If they turn on when the temperature is already high, it’s too late to do anything about the extreme heat inside my apartment. To overcome this dilemma, I used the temperature outside my house as a condition to determine the moment when my fans have to turn on. For this to work, I need to know exactly what the temperature on my balcony is at any given moment. Data from local weather services will deviate, since their weather stations will be much lower on the ground and don’t have to deal with the same amount of sun hours. So, I bought a temperature and humidity sensor and placed it on my balcony to get my own weather data. I called that sensor ‘balcony temperature’.

After that, I created my automations. I will focus on the automations for my bedroom in this article. The climate control in the living room will be identical. There are two types of automations: one which turns the bedroom fan switch on when needed and the other one turns it off when needed. I had to create multiple automations for both types to prevent conflicting conditions.

Let’s start with the automations to turn on the fan. I wanted the fan to turn on when the bedroom temperature rises above 23.49 degrees Celsius, but only when the balcony temperature is above 25.5 degrees. I also added the bedroom temperature as a condition and the balcony temperature as a trigger. Now the automation also starts when the temperature on the balcony gets above 25.5 degrees, after the bedroom temperature gets above 23.49. Next, I added the climate control switch as a trigger, as well as a condition. The trigger is a state change from off to on and the condition is that the climate control switch has to be on. I did the same thing with the away mode switch, so that the fan turns on when I arrive at home and won’t turn on when I’m away. I also created a time based trigger at 21:00 or 9 PM and a time condition so that the automation will only be executed between 21:00 and 10:00. Lastly, I added one action to turn on the bedroom fan. This is the result:

  alias: Climate Control - Bedroom fan
  description: ''
  trigger:
  - above: 23.49
    device_id: 6c638a49dd0e4d6b8185dabc2ae046eb
    domain: sensor
    entity_id: sensor.bedroom_temperature
    platform: device
    type: temperature
  - above: 25.5
    device_id: 728ca2b7081245828452761ae448aa46
    domain: sensor
    entity_id: sensor.balcony_temperature
    platform: device
    type: temperature
  - entity_id: switch.night_mode
    from: 'on'
    platform: state
    to: 'off'
  - at: '21:00:00'
    platform: time
  condition:
  - above: 25.5
    condition: device
    device_id: 728ca2b7081245828452761ae448aa46
    domain: sensor
    entity_id: sensor.balcony_temperature
    type: is_temperature
  - above: 23.49
    condition: device
    device_id: 6c638a49dd0e4d6b8185dabc2ae046eb
    domain: sensor
    entity_id: sensor.bedroom_temperature
    type: is_temperature
  - after: '21:00:00'
    before: '10:00:00'
    condition: time
  - condition: state
    entity_id: switch.climate_control
    state: 'on'
  - condition: state
    entity_id: switch.away_mode
    state: 'off'
  action:
  - data: {}
    entity_id: switch.bedroom_fan
    service: switch.turn_on
  mode: single

I created a second automation to turn on the fans in both the bedroom and the living room at the same time. The actions and conditions for the away mode and climate control are the same, but the rest is different. This time, I wanted the fan to turn on when the bedroom and living room temperature are above 25 degrees. I added this as a condition, not as a trigger. The only extra condition I added to this automation is that the sun must be below the horizon. Now, my fans also turn on when I arrive at home late in the evening or early at night and I just want to ventilate the room. I did this to create more opportunities to turn on the fans after dark, when the temperature outside is less likely to be above 25 degrees.

  alias: Climate Control - Away mode turns off and it's hot in the evening
  description: ''
  trigger:
  - entity_id: switch.away_mode
    from: 'on'
    platform: state
    to: 'off'
  condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon
  - above: 25
    condition: device
    device_id: 6c638a49dd0e4d6b8185dabc2ae046eb
    domain: sensor
    entity_id: sensor.bedroom_temperature
    type: is_temperature
  - above: 25
    condition: device
    device_id: 85d7d07dd14247a6b8ea05eecb47056b
    domain: sensor
    entity_id: sensor.lv_temperature
    type: is_temperature
  - condition: state
    entity_id: switch.climate_control
    state: 'on'
  action:
  - data: {}
    entity_id: switch.bedroom_fan
    service: switch.turn_on
  - data: {}
    entity_id: switch.living_room_fan
    service: switch.turn_on
  mode: single

The fan in my bedroom makes a lot of noise. This won’t help me to fall a sleep. So I made an extra automation to slow the windspeed down when night mode is activated. I added the night mode state change as a trigger and as a condition. I did the same with the fan. By doing so, the wind speed also slows down when the fan turned on after night mode was activated.

  alias: Night mode and bedroom fan on
  description: ''
  trigger:
  - entity_id: switch.night_mode
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: switch.bedroom_fan
    for: 00:00:06
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.bedroom_tv
    state: 'on'
  - condition: state
    entity_id: switch.night_mode
    state: 'on'
  - condition: state
    entity_id: switch.bedroom_fan
    state: 'on'
  action:
  - data: {}
    service: rest_command.br_fan_speed
  mode: single

Last but not least, I created an automation to turn off the fan. This one is really simple, since it has no conditions except for the climate control switch. This automation triggers when I leave the house or when the bedroom temperature gets between 19.49 and 22 degrees. I specified this trash hold so that I can use this automation also to turn off the heating.

  alias: Climate Control - Bedroom off
  description: ''
  trigger:
  - entity_id: switch.away_mode
    from: 'off'
    platform: state
    to: 'on'
  - above: 19.49
    below: 22
    device_id: 6c638a49dd0e4d6b8185dabc2ae046eb
    domain: sensor
    entity_id: sensor.bedroom_temperature
    for:
      hours: 0
      minutes: 30
      seconds: 0
    platform: device
    type: temperature
  condition:
  - condition: state
    entity_id: switch.climate_control
    state: 'on'
  action:
  - data: {}
    entity_id: switch.bedroom_fan
    service: switch.turn_off
  - data: {}
    entity_id: climate.bedroom_thermostat
    service: climate.turn_off
  mode: single

The heating is another part of this climate control system, to which I will come back as soon as I made it myself. I’m planning to reduce my energy bill some more, by making good use of the sun hours when it’s cold outside.

Furthermore, I’m thinking about changing the controls of my fans to the generic thermostat platform. This way, I can leave the trash hold out of the automation above and change the behavior with a simple twist of the dial.

I will keep you posted on the progress of my climate system. Suggestions or questions? Let me know!