From 3fd51d3d2617a6dfab389ae8fb33d863ed663200 Mon Sep 17 00:00:00 2001 From: MobilettoSoft Date: Mon, 26 May 2025 10:33:39 +0200 Subject: [PATCH] Renault: add E-tech vehicles wakeup mode (BC) (#21432) --- templates/definition/vehicle/renault.yaml | 15 ++++++++++++--- vehicle/renault.go | 11 ++++++----- vehicle/renault/kamereon/api.go | 15 +++++++++++++++ vehicle/renault/kamereon/types.go | 13 +++++++++++++ vehicle/renault/provider.go | 10 +++++++--- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/templates/definition/vehicle/renault.yaml b/templates/definition/vehicle/renault.yaml index 0ebeda19a..6ab347f28 100644 --- a/templates/definition/vehicle/renault.yaml +++ b/templates/definition/vehicle/renault.yaml @@ -8,10 +8,19 @@ params: - name: alternativewakeup type: bool description: - de: Alternativer Aufweckmechanismus - en: Alternative wakeup mechanism + de: Alternative Aufweckmechanismus (veraltet) + en: Alternative wakeup mechanism (deprecated) + advanced: true + deprecated: true + - name: wakeupmode + type: choice + choice: ["default", "alternative", "MY24"] + default: default + description: + de: Aufweckmechanismus + en: Wakeup mechanism advanced: true render: | type: renault {{ include "vehicle-base" . }} - alternativewakeup: {{ .alternativewakeup }} + wakeupmode: {{ .wakeupmode }} diff --git a/vehicle/renault.go b/vehicle/renault.go index 26ce3f4a0..06c43e60a 100644 --- a/vehicle/renault.go +++ b/vehicle/renault.go @@ -40,13 +40,14 @@ func NewRenaultDaciaFromConfig(brand string, other map[string]interface{}) (api. cc := struct { embed `mapstructure:",squash"` User, Password, Region, VIN string - AlternativeWakeup bool + WakeupMode string Cache time.Duration Timeout time.Duration }{ - Region: "de_DE", - Cache: interval, - Timeout: request.Timeout, + Region: "de_DE", + WakeupMode: "default", + Cache: interval, + Timeout: request.Timeout, } if err := util.DecodeOther(other, &cc); err != nil { @@ -94,7 +95,7 @@ func NewRenaultDaciaFromConfig(brand string, other map[string]interface{}) (api. err = vehicle.Available() } - v.Provider = renault.NewProvider(api, accountID, vehicle.VIN, cc.AlternativeWakeup, cc.Cache) + v.Provider = renault.NewProvider(api, accountID, vehicle.VIN, cc.WakeupMode, cc.Cache) return v, err } diff --git a/vehicle/renault/kamereon/api.go b/vehicle/renault/kamereon/api.go index 3991a2e97..c1c9f9b44 100644 --- a/vehicle/renault/kamereon/api.go +++ b/vehicle/renault/kamereon/api.go @@ -138,6 +138,21 @@ func (v *API) WakeUp(accountID string, vin string) (Response, error) { return v.request(uri, request.MarshalJSON(data)) } +func (v *API) WakeUpMY24(accountID string, vin string) (Response, error) { + uri := fmt.Sprintf("%s/commerce/v1/accounts/%s/kamereon/kcm/v1/vehicles/%s/ev/settings", v.keys.Target, accountID, vin) + + data := EvSettingsRequest{ + LastSettingsUpdateTimestamp: "2025-04-24T12:41:41.823Z", + DelegatedActivated: false, + ChargeModeRq: "SCHEDULED", + ChargeTimeStart: "21:00", + ChargeDuration: 1615, + PreconditioningTemperature: 20.0, + } + + return v.request(uri, request.MarshalJSON(data)) +} + func (v *API) Position(accountID string, vin string) (Response, error) { uri := fmt.Sprintf("%s/commerce/v1/accounts/%s/kamereon/kca/car-adapter/v1/cars/%s/location", v.keys.Target, accountID, vin) return v.request(uri, nil) diff --git a/vehicle/renault/kamereon/types.go b/vehicle/renault/kamereon/types.go index 275748856..aaac290c1 100644 --- a/vehicle/renault/kamereon/types.go +++ b/vehicle/renault/kamereon/types.go @@ -70,3 +70,16 @@ type attributes struct { Latitude float64 `json:"gpsLatitude"` Longitude float64 `json:"gpsLongitude"` } + +type EvSettingsRequest struct { + LastSettingsUpdateTimestamp string `json:"lastSettingsUpdateTimestamp"` + DelegatedActivated bool `json:"delegatedActivated"` + ChargeModeRq string `json:"chargeModeRq"` + ChargeTimeStart string `json:"chargeTimeStart"` + ChargeDuration int `json:"chargeDuration"` + PreconditioningTemperature float64 `json:"preconditioningTemperature"` + PreconditioningHeatedStrgWheel bool `json:"preconditioningHeatedStrgWheel"` + PreconditioningHeatedRightSeat bool `json:"preconditioningHeatedRightSeat"` + PreconditioningHeatedLeftSeat bool `json:"preconditioningHeatedLeftSeat"` + Programs []interface{} `json:"programs"` +} diff --git a/vehicle/renault/provider.go b/vehicle/renault/provider.go index e8b72d366..e9f997368 100644 --- a/vehicle/renault/provider.go +++ b/vehicle/renault/provider.go @@ -24,7 +24,7 @@ type Provider struct { } // NewProvider creates a vehicle api provider -func NewProvider(api *kamereon.API, accountID, vin string, alternativeWakeup bool, cache time.Duration) *Provider { +func NewProvider(api *kamereon.API, accountID, vin string, wakeupMode string, cache time.Duration) *Provider { impl := &Provider{ batteryG: util.Cached(func() (kamereon.Response, error) { return api.Battery(accountID, vin) @@ -36,10 +36,14 @@ func NewProvider(api *kamereon.API, accountID, vin string, alternativeWakeup boo return api.Hvac(accountID, vin) }, cache), wakeup: func() (kamereon.Response, error) { - if alternativeWakeup { + switch wakeupMode { + case "alternative": return api.Action(accountID, kamereon.ActionStart, vin) + case "MY24": + return api.WakeUpMY24(accountID, vin) + default: + return api.WakeUp(accountID, vin) } - return api.WakeUp(accountID, vin) }, position: func() (kamereon.Response, error) { return api.Position(accountID, vin)