feat: per-CPU temperature sensors over MQTT/Home Assistant#12
Merged
Conversation
Publish one HA discovery sensor per CPU socket (cpu0_temp, cpu1_temp, ...) alongside a cpus[] array in the retained state document, mirroring the existing per-GPU implementation. The monitor already read both sockets into CPUReading.Temps; only the max was ever published. The aggregate cpu_temp sensor is preserved (fan logic and HA history depend on it) and relabeled 'CPU Temperature (Max)' for parity with the GPU max sensor. Per-CPU discovery is published lazily on first successful state publish, mutex-guarded and cleared on reconnect, matching the GPU cold-start handling. Scales to N sockets. Confined to internal/mqtt; the control loop stays MQTT-unaware. Task: dex yqkz8t1k — Per-CPU temperature sensors over MQTT/HA Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Breaks out per-CPU-socket temperatures over MQTT so Home Assistant shows one temperature sensor per physical CPU, not just a single aggregate. On a two-socket R730 (e.g. bandit) this turns 1 CPU sensor into 3: CPU 1, CPU 2, and the existing max.
Mirrors the per-GPU implementation shipped in v1.2.0.
Changes (all in
internal/mqtt/)cpusarray — one{index, temp}per socket, sourced fromstatus.CPU.Temps(already read; only.Maxwas published before).cpuN_tempHA sensors (0-based idscpu0_temp/cpu1_temp, 1-based labels "CPU 1/2 Temperature"),device_class: temperature, °C, cold-start-safedefault('')value_templates indexingvalue_json.cpus[i].temp.publishNewCPUDiscoverymirrorspublishNewGPUDiscovery— mutex-guarded, gated on a successful state publish, cleared on reconnect (handles connect-before-first-read).cpu_temp(max) sensor unchanged in id/value key, relabeled "CPU Temperature (Max)" for parity with the GPU max sensor. Fan logic and existing HA history depend on it.internal/controlleruntouched — control loop stays MQTT-unaware.Test evidence
go vet ./...clean ·CGO_ENABLED=1 go build ./cmd/controllerok ·go test -race -count=1 ./...all 8 packages pass.cpus[].temp, aggregate relabel.--demo— observed"cpus":[{"index":0,"temp":41},{"index":1,"temp":42}], bothcpuN_temp/configdiscovery messages with correct topics/labels, aggregate relabeled, values updating per tick, all confirmed as retained messages.Task: dex yqkz8t1k
🤖 Generated with Claude Code