Sponsor: include device serial in hardware check metadata (#32927)

This commit is contained in:
Michael Geers 2026-08-18 12:02:29 +02:00 • committed by GitHub
parent cc92f3938a
commit f4b289f745
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,11 +20,23 @@ package sponsor
// SOFTWARE.
import (
"os"
"strings"
i2c "github.com/d2r2/go-i2c"
)
const hemspro = "hemspro"
// deviceSerial returns the device tree serial number or empty string
func deviceSerial() string {
b, err := os.ReadFile("/sys/firmware/devicetree/base/serial-number")
if err != nil {
return ""
}
return strings.TrimSpace(strings.Trim(string(b), "\x00"))
}
// checkHemsPro checks if the hardware is a supported HEMS Pro device and returns sponsor subject
func checkHemsPro() string {
const (
@ -49,5 +61,7 @@ func checkHemsPro() string {
}
// I2C succeeded — verify with server
return checkHardware(hemspro, nil)
return checkHardware(hemspro, map[string]string{
"serial": deviceSerial(),
})
}