Revert "Renault: update api"

This reverts commit 9eb918b3ac.
This commit is contained in:
andig 2024-06-17 15:58:24 +02:00
parent 8633283ab7
commit e353083a31
2 changed files with 15 additions and 6 deletions

View file

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

View file

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