# ha-gpu-ccd - Home Assistant GPU CCD Temperature Monitor A tool that retrieves GPU temperature information from Home Assistant MQTT and writes it to sysfs format files. ## Features - Listen to Home Assistant MQTT temperature topics (supports multiple subscription modes) - Convert temperature from Celsius to millidegrees (e.g., 80.5°C -> 80500) - Write temperature to `/tmp/temp_{DEVICEID}` files (sysfs format) - Support for monitoring specific devices or all devices ## Build ```bash go build ``` ## Usage ```bash ./ha-gpu-ccd --mqtt-host --mqtt-port --mqtt-username --mqtt-password ``` ### Parameters - `--mqtt-host`: MQTT broker host (default: localhost) - `--mqtt-port`: MQTT broker port (default: 1883) - `--mqtt-username`: MQTT username (optional) - `--mqtt-password`: MQTT password (optional) - `--temp-dir`: Directory to write temperature files (default: /tmp) - `--device-id`: Specific GPU device ID to monitor (leave empty to monitor all devices) ### Examples ```bash # Connect to local MQTT broker, monitor all GPUs ./ha-gpu-ccd # Connect to remote MQTT broker with authentication ./ha-gpu-ccd --mqtt-host 192.168.1.100 --mqtt-username homeassistant --mqtt-password mypassword # Monitor only specific GPU device ./ha-gpu-ccd --device-id 00_04_00_0 # Custom temperature file directory ./ha-gpu-ccd --temp-dir /var/lib/gpu-temps # Combined usage: specific device with authentication ./ha-gpu-ccd --mqtt-host 192.168.1.100 --mqtt-username user --mqtt-password pass --device-id 00_04_00_0 ``` ## Output Format The tool creates a temperature file for each GPU device: - File name: `temp_{DEVICEID}` - Content: Temperature value in millidegrees (integer) - Location: Default in `/tmp/` directory Example: - GPU device ID: `00_04_00_0` - Temperature: 80.5°C - File: `/tmp/temp_00_04_00_0` - Content: `80500` ## MQTT Topic Format The tool supports two subscription modes: ### Monitor All Devices (Default Mode) Subscribe topic: `homeassistant/sensor/nvml-gpu/#` Filter condition: Only process messages containing `_temperature/state` ### Monitor Specific Device Subscribe topic: `homeassistant/sensor/nvml-gpu/{DEVICEID}_temperature/state` Temperature topic format: ``` homeassistant/sensor/nvml-gpu/{DEVICEID}_temperature/state ``` Where `{DEVICEID}` is the device ID generated by the nvml-gpu-ha main program, e.g., `00_04_00_0` ## Logging The tool outputs the following log messages: - Connection status - Subscription status - Received temperature data - File write status - Error messages ## Troubleshooting 1. **Connection Failed**: Check if MQTT broker address and port are correct 2. **Authentication Failed**: Verify username and password are correct 3. **Subscription Failed**: Ensure MQTT broker supports wildcard subscriptions 4. **No Data Received**: Check if nvml-gpu-ha main program is running and sending data ## Integration This tool is designed for integration with other systems, such as: - System monitoring software - Temperature control systems - Automation scripts By reading the `/tmp/temp_{DEVICEID}` files, other programs can obtain real-time GPU temperature information.