diff --git a/server/http_config_helper.go b/server/http_config_helper.go index 6db0361fe..1d187a1df 100644 --- a/server/http_config_helper.go +++ b/server/http_config_helper.go @@ -130,6 +130,11 @@ type testResult = struct { Error string `json:"error"` } +func hasFeature(instance any, f api.Feature) bool { + fd, ok := instance.(api.FeatureDescriber) + return ok && slices.Contains(fd.Features(), f) +} + // testInstance tests the given instance similar to dump // TODO refactor together with dump func testInstance(instance any) map[string]testResult { @@ -159,7 +164,7 @@ func testInstance(instance any) map[string]testResult { if dev, ok := instance.(api.Battery); ok { val, err := dev.Soc() key := "soc" - if fd, ok := instance.(api.FeatureDescriber); ok && slices.Contains(fd.Features(), api.Heating) { + if hasFeature(instance, api.Heating) { key = "temp" } makeResult(key, val, err) @@ -225,7 +230,7 @@ func testInstance(instance any) map[string]testResult { if dev, ok := instance.(api.SocLimiter); ok { val, err := dev.GetLimitSoc() key := "vehicleLimitSoc" - if fd, ok := instance.(api.FeatureDescriber); ok && slices.Contains(fd.Features(), api.Heating) { + if hasFeature(instance, api.Heating) { key = "heaterTempLimit" } makeResult(key, val, err)