Python script to monitor the raid status provided by mdadm with home assistant auto configuration
- Option to execute mdadm as sudo
- Rewritten connection handler (last will, online status)
- Pass configuration file as argument
- Added MQTT username and password
- Default configuration built-in
- Updated systemd script
- Raid status
- Last update timestamp
- Total disk space (default in GB, can be configured)
- Free disk space
- Free disk space in percent
- Used disk space
- python 3.9 (other versions might work)
- paho-mqtt
- psutil
- mdadm, blkid, uname
Python requirements can be installed with pip3 install -r requirements.txt
Edit config.json
to change or add your device name and raid devices
Any raid device /dev/mdX
can be added (raid_device
). The device must be mounted (mount_point
) to gather file system information
Execute check-raid.py -v
as root
. mdadm
requires root privileges to be executed. If run as sudo has been enabled, the current user must be able to execute sudo mdadm
without a password
Copy hass_raid_status.service
to your systemd directory, modify the location of the python script and add any required services (for example mosquitto as dependency)
Enable, start and check the service with EEE
systemctl enable hass_raid_status.service
systemctl start hass_raid_status.service
systemctl status hass_raid_status.service
● hass_raid_status.service - Raid status for Home Assistant
Loaded: loaded (/etc/systemd/system/hass_raid_status.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-02-17 04:19:54 PST; 27ms ago
Main PID: 14967 (python3)
Tasks: 1 (limit: 4915)
CPU: 14ms
CGroup: /system.slice/hass_raid_status.service
└─14967 python3 /root/hass_mqtt_raid_status/check-raid.py
The device can be found under Configuration / Devices (http://homeassistant.local:8123/config/devices/dashboard)
To trigger any alarm if the raid fails, you can add an automation if the state of the sensor changes from Clean
or Active
to another state
- Degraded mirrored raid during rebuild
Clean,degraded,recovering
- Degraded mirrored raid with missing drive
Clean,degraded