Added support for Climater

This commit is contained in:
Andreas Linde 2021-03-21 12:13:16 +01:00
parent bbb3d940f8
commit d665e1df70
No known key found for this signature in database
GPG key ID: 96178502495847D9

View file

@ -60,7 +60,8 @@ type porscheEmobilityResponse struct {
IsActive bool
}
DirectClimatisation struct {
ClimatisationState string
ClimatisationState string
RemainingClimatisationTime int64
}
}
@ -362,3 +363,18 @@ func (v *Porsche) Range() (int64, error) {
return 0, err
}
// Climater implements the api.VehicleClimater interface
func (v *Porsche) Climater() (active bool, outsideTemp float64, targetTemp float64, err error) {
res, err := v.chargerG()
if res, ok := res.(porscheEmobilityResponse); err == nil && ok {
switch res.DirectClimatisation.ClimatisationState {
case "OFF":
return false, 0, 0, nil
case "ON":
return true, 0, 0, nil
}
}
return active, outsideTemp, targetTemp, err
}