Renault: update api

This commit is contained in:
andig 2024-06-01 18:13:48 +02:00
parent aa4e26e316
commit 9eb918b3ac
2 changed files with 6 additions and 15 deletions

View file

@ -62,7 +62,7 @@ type attributes struct {
RemainingTime *int `json:"chargingRemainingTime"`
// hvac-status
ExternalTemperature float64 `json:"externalTemperature"`
HvacStatus string `json:"hvacStatus"`
HvacStatus int `json:"hvacStatus"`
// cockpit
TotalMileage *float64 `json:"totalMileage"`
// position

View file

@ -2,8 +2,6 @@ package renault
import (
"net/http"
"slices"
"strings"
"time"
"github.com/evcc-io/evcc/api"
@ -138,23 +136,16 @@ var _ api.VehicleClimater = (*Provider)(nil)
// Climater implements the api.VehicleClimater interface
func (v *Provider) Climater() (bool, error) {
res, err := v.hvacG()
// Zoe Ph2, Megane e-tech
if err, ok := err.(request.StatusError); ok && err.HasStatus(http.StatusForbidden, http.StatusBadGateway) {
return false, api.ErrNotAvailable
}
if err == nil {
state := strings.ToLower(res.Data.Attributes.HvacStatus)
if state == "" {
if err != nil {
// Zoe Ph2, Megane e-tech
if err, ok := err.(request.StatusError); ok && err.HasStatus(http.StatusForbidden, http.StatusBadGateway) {
return false, api.ErrNotAvailable
}
active := !slices.Contains([]string{"off", "false", "invalid", "error"}, state)
return active, nil
return false, err
}
return false, err
return res.Data.Attributes.HvacStatus > 0, nil
}
var _ api.Resurrector = (*Provider)(nil)