This is a telemetry service written in Go that publishes information about the server to a MQTT broker. This service has been designed to be used with a Home Assistant, for which all devices and sensors will show up automatically up when autodiscovery is enabled.
-
Install Go and Git on your system (If you haven't yet)
-
Clone this repository
-
In the root of the repository run: go build -ldflags="-s -w" main.go
-
Mark the executable as executable (If you're on linux): chmod +x main
-
Copy that executable wherever it fits best to you as also thec configuration.yaml file. (Recommended: /opt/server-telemetry/)
-
Edit the configuration.yaml file to your linking.
-
Run the binary and that's it. (By default the binary searches for configuration.yaml, a custom path to the configuration file can be set as first argument to the executable)
-
(optional) create service to autostart the script at boot:
- sudo nano /etc/systemd/system/system-telemetry-sensor.service
- Copy the following content into the service file:
[Unit] Description=Home Assistant System Telemetry Sensor service After=multi-user.target
[Service] User=[user] Type=idle ExecStart=/opt/server-telemetry/telemetry-service /opt/server-telemetry/configuration.yaml
[Install] WantedBy=multi-user.target
- Edit the path to your script path and configuration.yaml. Also make sure you replace [user] with the account from which this script will be run.
- sudo systemctl enable system-telemetry-sensor.service
- sudo systemctl start system-telemetry-sensor.service
Tested on an Asus RT-AC68U. Before the compilation step set the following environment variables:
set GOOS=linux set GOARCH=arm set GOARM=5
You can reduce the size of the binary by commenting out the drivers used in driver/driver.go. This might be improved in the future by using compiler flags.
- Automatic removal of disabled sensors is missing. (WORKAROUND: Removing the device from HASS and restarting the service)
- Add support for AsusWRT device temperature measuring (cat /proc/dmu/temperature)
- AsusWRT Device Tracking
The project was inspired by: https://github.com/Sennevds/system_sensors