diff --git a/util/sponsor/hemspro_linux.go b/util/sponsor/hemspro_linux.go index c2e3d144e..7180441af 100644 --- a/util/sponsor/hemspro_linux.go +++ b/util/sponsor/hemspro_linux.go @@ -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(), + }) }