Homeassistant vehicle: allow float values for range and limit soc

This commit is contained in:
andig 2025-10-17 17:59:08 +02:00
parent 0bc4ff8d8d
commit 38673442ba

View file

@ -83,13 +83,19 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error
)
if cc.Sensors.LimitSoc != "" {
limitSoc = func() (int64, error) { return conn.GetIntState(cc.Sensors.LimitSoc) }
limitSoc = func() (int64, error) {
f, err := conn.GetFloatState(cc.Sensors.LimitSoc)
return int64(f), err
}
}
if cc.Sensors.Status != "" {
status = func() (api.ChargeStatus, error) { return conn.GetChargeStatus(cc.Sensors.Status) }
}
if cc.Sensors.Range != "" {
rng = func() (int64, error) { return conn.GetIntState(cc.Sensors.Range) }
rng = func() (int64, error) {
f, err := conn.GetFloatState(cc.Sensors.Range)
return int64(f), err
}
}
if cc.Sensors.Odometer != "" {
odo = func() (float64, error) { return conn.GetFloatState(cc.Sensors.Odometer) }