Homebrew fridge control using the IKEA control outlet and Aqara multisensor

Homebrew fridge control using the IKEA control outlet and Aqara multisensor.

With inspiration from Inkbird and the very well written and helpful wake-up light guide from Woulter Bulten I set out on my first HA project, trying to automate my new homebrewing fridge.

The two parts I used for this project was the IKEA Trådfri Control Outlet as well as the Aqara Multisensor (not counting the pi and conbee 2).

Aqara Multisensor

Inputs to the automation is handled through the following dashboard widget.

Dashboard widget

Which is defined in groups.yaml as

fridge_control:
  name: "Fridge Control"
  entities:
    - input_boolean.fridge_control_enabled # Dashboard input defined in configuration.yaml
    - sensor.temperature_4 # Input from temp sensor
    - input_number.fridge_target_temp # Dashboard input defined in configuration.yaml
    - input_number.fridge_temp_diff # Dashboard input defined in configuration.yaml
    - input_datetime.fridge_on_off_delay # Dashboard input defined in configuration.yaml
    - switch.fridge_status # Status of control outlet

Custom variables used above are defined in configuration.yaml as

input_boolean :
  fridge_control_enabled:
    name: "Fridge temperature control"
    icon: mdi:fridge-outline

input_datetime:
  # Fridge control
  fridge_on_off_delay:
    name: "On/Off delay"
    has_time: true
    has_date: false

input_number:
  # Fridge control
  fridge_target_temp:
    name: "Target temperature"
    min: 0
    max: 30
    step: 0.5
    mode: box
    unit_of_measurement: °C
    icon: mdi:thermometer
  fridge_temp_diff:
    name: "Target allowed differential"
    min: 0.1
    max: 2
    step: 0.1
    mode: box
    unit_of_measurement: °C
    icon: mdi:delta

timer:
  fridge_on_off_delay:

Which also contains a timer fridge_on_off_delay which I´ll explain later.

When mounting the sensor you want it to be as close to the liquid as possible as this is the temperature you want to control. I did this using a reasonably sized piece of styrofoam which I carved out a multisensor sized hole in. I then taped this to the side of my fermentation vessel at liquid level and sealed the sides with some poster putty.

Back to the dashboard widget.

Dashboard widget

Fridge temperature control: This just turn the whole automation on and off.
Current temperature: Self explanatory, this is the input from the multisensor.
Target temperature: Also quite self explanatory, this is the target temperature you want your liquid to have.
Target allowed differential: This is the allowed positive differential that you allow your liquid to have before the fridge will turn on.
On/Off delay: This is used (inspired by inkbird) as a minimum time which the fridge has to be on for after switching on. I believe this is to save your fridge from the pain of turning on and off frequently, of course at the price that your brew could go colder than desired. Since my liquid takes such a long time to reach the lower temperature limit i´ve never had this trigger though (this is also where the timer is used).
Fridge status: This is just the status of the control outlet.

The code in automations.yaml which control this looks as follows

- alias: Start fridge on/off delay timer
  trigger:
    platform: state
    entity_id: switch.fridge_status
    state: 'on'
  condition: []
  action:
  - service: timer.start
    entity_id: timer.fridge_on_off_delay
    data_template:
      duration: '{{ states(''input_datetime.fridge_on_off_delay'') }}'
- alias: Turn fridge on if temperature is to high
  trigger:
    platform: template
    value_template: '{{ states(''sensor.temperature_4'') | float > (states(''input_number.fridge_target_temp'')
      | float + states(''input_number.fridge_temp_diff'') | float) }}'
  condition:
  - condition: state
    entity_id: input_boolean.fridge_control_enabled
    state: 'on'
  action:
    service: switch.turn_on
    entity_id: switch.fridge_status
- alias: Turn fridge off if temperature is on target or colder
  trigger:
    platform: template
    value_template: '{{ states(''sensor.temperature_4'') <= states(''input_number.fridge_target_temp'')
      }}'
  condition:
  - condition: state
    entity_id: input_boolean.fridge_control_enabled
    state: 'on'
  - condition: state
    entity_id: timer.fridge_on_off_delay
    state: 'idle'
  action:
    service: switch.turn_off
    entity_id: switch.fridge_status
- alias: Check if fridge needs to be turned off when timer runs out
  trigger: 
    platform: state
    entity_id: timer.fridge_on_off_delay
    from: 'active'
    to: 'idle'
  condition:
  - condition: state
    entity_id: input_boolean.fridge_control_enabled
    state: 'on'
  - condition: state
    entity_id: switch.fridge_status
    state: 'on'
  - condition: template
    value_template: '{{ states(''sensor.temperature_4'') <= states(''input_number.fridge_target_temp'') }}'
  action:
    service: switch.turn_off
    entity_id: switch.fridge_status

And the result looks like this

I´ve had it running for two weeks now with no problems.

Notes!

  • I have my fridge standing inside of my house which always keeps an outside temperature (outside the fridge, inside the house) which is higher than what I want my liquid to be, so that is the only case I have considered when designing this.
  • There is some undershoot when the fridge is turned off where the liquid will keep going lower for some time as seen in the resulting temperature graph.
  • There is certainly alot of parts in this that could be improved and written in alot more compact way.

Otherwise I hope some of this will be useful for someone and happy homebrewing!

8 Likes