Close

Setting up automation in Home Assistant!

A project log for Fresh air automation by RF usb dongle

Wireless USB dongle (868MHz) for home automation to improve the indoor air quality (IAQ)

marcelMarcel 06/06/2022 at 17:270 Comments

In this log, I will try to create an automation in Home Assistant, that controls the ventilation speed in a smart way so that the indoor temperature during the summertime will not become as hot. The idea is basically to control the ventilation speed, based on this configuration:

Increase ventilation speed to level 3:


T
riggers:

- Someone leaves the house (leaves a zone)
- It's 8 o'clock in the morning


The conditions that should be met:
- And: everyone is away from the zone (each smartphone is away)
- And: the actual outdoor temperature should be below 20°C
- And: time should be between 6 o'clock and 12
- And: the forecasted outdoor temperature should be more than 25°C

Actions:
- Set fan speed level to: 2 or 3
- Send a message to my phone (testing purposes)

The HA script:

- id: 'xxxxxxxxxx'
  alias: Start smart ventilation
  trigger:
  - platform: time
    at: 08:00:00
  - platform: device
    device_id: XXXXXXXXXXXX
    domain: device_tracker
    entity_id: device_tracker.marcel
    type: leaves
    zone: zone.home
  - platform: device
    device_id: XXXXXXXXXXXX
    domain: device_tracker
    entity_id: device_tracker.mywife
    type: leaves
    zone: zone.home
  condition:
  - condition: and
    conditions:
    - condition: device
      device_id: XXXXXXXXXXXX
      domain: device_tracker
      entity_id: device_tracker.marcel
      type: is_not_home
    - condition: device
      device_id: XXXXXXXXXXXX
      domain: device_tracker
      entity_id: device_tracker.mywife
      type: is_not_home
    - condition: numeric_state
      entity_id: weather.huis
      attribute: temperature
      below: '20'
    - condition: time
      after: 06:00:00
      before: '12:00:00'
    - condition: numeric_state
      entity_id: weather.huis
      attribute: forecast
      above: '25'
  action:
  - type: turn_on
    device_id: XXXXXXXXXXXX
    entity_id: light.fan_speed_setpoint
    domain: light
    brightness_pct: 2
  - service: notify.mobile_app_marcel
    data:
      title: Ventilation started!
      message: The ventilation speed is set to: 2
  mode: single


Set back ventilation speed to level 1:


Triggers:

- Someone gets home (enters a zone)
- The actual outdoor temperature has reached more than 20°C

Actions:
- Set fand speed level to: 1

The HA script:

- id: 'xxxxxxxxxx'
  alias: Stop ventilation
  trigger:
  - platform: device
    device_id: XXXXXXXXXXXX
    domain: device_tracker
    entity_id: device_tracker.marcel
    type: enters
    zone: zone.home
  - platform: device
    device_id: XXXXXXXXXXXX
    domain: device_tracker
    entity_id: device_tracker.mywife
    type: enters
    zone: zone.home
  - platform: numeric_state
    entity_id: weather.huis
    attribute: temperature
    above: '20'
  condition: []
  action:
  - type: turn_on
    device_id: XXXXXXXXXXXX
    entity_id: light.fan_speed_setpoint
    domain: light
    brightness_pct: 1
  mode: single

As you can see from the script, the FAN speed is treated like a light (dimming), this "issue" is described in the project details section.

Now it's waiting for the summertime to see if the automation works well..... but more importantly, if it really improves the temperature and air quality :)

Discussions