# Keeping My Comms Rack Cool with Home Assistant

Source: https://jackwent.co.uk/home-assistant-server-rack-cooling/
Published: 2026-09-12. Updated: 2026-10-11. By Jack Went.

> How Home Assistant runs my rack fans, cools the UPS battery, watches NAS drive temperatures and warns me about leaks, with the automations to copy.

My network kit lives in a small comms rack, with a UPS at the bottom and a QNAP NAS full of spinning drives. (If you're planning a NAS of your own, the [RAID and ZFS capacity calculator](/raid-capacity-calculator/) shows how much space each layout leaves you.) Small racks get warm, UPS batteries hate heat, and water anywhere near the lot is a disaster. Home Assistant looks after all four for me with a handful of very simple automations.

None of these are clever. That's the point. Each one does one job, and between them I don't have to think about the rack at all.

Image: A black wall mounted comms rack with its glass door open, showing a fan grille in the top, network kit with labelled cables, a QNAP NAS and a power strip at the bottom

The rack with the door open. The fan is in the roof of the cabinet, above the network kit, the QNAP NAS and the power strip.

## Rack fans that switch themselves

There's a temperature sensor inside the rack, and the cabinet's own roof fan is plugged into an [ESPHome](https://esphome.io/) smart plug, so Home Assistant can switch it. The fans come on above 21°C and go off below 19°C.

The gap between those two numbers matters. If the fans turned on at 20°C and off at 20°C, they'd flick on and off every few minutes as the temperature hovered around the line. With a two degree gap (called hysteresis), they run until the rack has properly cooled and then stay off until it has properly warmed up.

Image: A Home Assistant history chart over three days: a bar showing the rack fan socket switching on and off in yellow, above a line graph of the rack temperature rising to about 21 degrees and dropping back to about 19 each time the fans run

Three days of the real thing in Home Assistant. Yellow is the fans running: the rack climbs to just over 21°C, the fans come on, and it drops back to about 19°C before they go off.

```yaml
alias: Rack fan control
mode: single
triggers:
  - trigger: numeric_state
    entity_id: sensor.rack_temperature
    above: 21
    id: hot
  - trigger: numeric_state
    entity_id: sensor.rack_temperature
    below: 19
    id: cold
  - trigger: homeassistant
    event: start
    id: restart
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: hot
        sequence:
          - action: switch.turn_on
            target:
              entity_id: switch.rack_fans
      - conditions:
          - condition: trigger
            id: cold
        sequence:
          - action: switch.turn_off
            target:
              entity_id: switch.rack_fans
      - conditions:
          - condition: trigger
            id: restart
        sequence:
          - delay:
              seconds: 30
          - if:
              - condition: numeric_state
                entity_id: sensor.rack_temperature
                above: 21
            then:
              - action: switch.turn_on
                target:
                  entity_id: switch.rack_fans
          - if:
              - condition: numeric_state
                entity_id: sensor.rack_temperature
                below: 19
            then:
              - action: switch.turn_off
                target:
                  entity_id: switch.rack_fans
```

### Why the restart trigger?

A `numeric_state` trigger only fires when the value **crosses** the threshold. If Home Assistant is restarting at the moment the rack goes past 21°C, it misses the crossing, and the fans won't come on until the temperature drops below 21°C and climbs back up again. On a hot day that could be hours.

So on every restart the automation waits thirty seconds for the sensors to come back, looks at the current temperature, and puts the fans in the right state. I'd add this to any automation that uses `above` or `below`.

## A fan for the UPS battery

UPS batteries age much faster when they run warm, and mine reports its battery temperature over SNMP. A little USB fan sits next to it, powered from a Zigbee USB switch. Same pattern as the rack: on above 31°C, off below 27°C.

```yaml
alias: UPS fan control
mode: single
triggers:
  - trigger: numeric_state
    entity_id: sensor.ups_battery_temperature
    above: 31
    id: above
  - trigger: numeric_state
    entity_id: sensor.ups_battery_temperature
    below: 27
    id: below
actions:
  - action: "switch.turn_{{ 'on' if trigger.id == 'above' else 'off' }}"
    target:
      entity_id: switch.ups_usb_fan
```

The UPS (a Smart-UPS 750) also reports its battery health. When the status changes to **Failed**, Home Assistant raises a notification with a fixed id, and a second automation dismisses it when the status goes back to **Good**, which happens when the new battery goes in. The notification stays put until the job is done, which is exactly what you want for something easy to put off.

This one has already done its job for real. The battery status went to **Failed**, the notification sat there until I'd fitted a new battery, and then it cleared itself without me touching it.

## NAS drives

The QNAP integration gives Home Assistant a temperature sensor for every drive in the NAS. If any of them goes over 60°C, Home Assistant sends a notification to my phone and raises one in Home Assistant too. That has never fired, which is how I like it, but drives that hot don't last long and I'd rather know.

## Leak sensors

Image: The comms rack with its glass door shut, mounted on a brick wall right next to the boiler

Door shut. The boiler sits right next to the rack, which is why there's a leak sensor under each of them.

Two Aqara water leak sensors sit on the floor, one under the rack and one under the boiler. If either gets wet I get a push notification and a persistent notification in Home Assistant saying which one. Water and a rack full of electrics don't mix, and a boiler leak is much cheaper to deal with when you find it early.

Leak sensors are one of the cheapest things you can add to a smart home, and one of the most useful. If you only buy one sensor after reading this, buy one of those.

## What I've learned

- **Use two thresholds, not one.** Anything that switches on and off based on a temperature needs a gap between the two numbers.
- **Plan for restarts.** Anything triggered by a value crossing a line should recheck when Home Assistant starts.
- **Fixed notification ids.** Give a notification an id and you can dismiss it automatically later, so alerts clear themselves when the problem goes away.

All of this sits alongside my [server alerts](/home-assistant-server-monitoring-alerts/), which tell me when one of my servers stops responding.
