Home Assistant: configurable charge status values (BC) (#32136)

This commit is contained in:
andig 2026-07-25 12:14:42 +02:00 • committed by GitHub
parent 36a789b5c0
commit c8b27650ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 204 additions and 35 deletions

View file

@ -37,6 +37,9 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error
Climater string // optional
FinishTime string // optional
}
StatusA string // optional - custom states mapped to status A
StatusB string // optional - custom states mapped to status B
StatusC string // optional - custom states mapped to status C
Services struct {
Start string `mapstructure:"start_charging"` // script.* or switch.* optional
Stop string `mapstructure:"stop_charging"` // script.* optional
@ -74,7 +77,12 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error
}))
}
if cc.Sensors.Status != "" {
implement.Has(res, implement.ChargeState(func() (api.ChargeStatus, error) { return conn.GetChargeStatus(cc.Sensors.Status) }))
states, err := homeassistant.NewStatusMap(cc.StatusA, cc.StatusB, cc.StatusC)
if err != nil {
return nil, err
}
implement.Has(res, implement.ChargeState(func() (api.ChargeStatus, error) { return conn.GetChargeStatus(cc.Sensors.Status, states) }))
}
if cc.Sensors.Range != "" {
implement.Has(res, implement.VehicleRange(func() (int64, error) {