diff --git a/templates/definition/vehicle/homeassistant.yaml b/templates/definition/vehicle/homeassistant.yaml index 2b63c198b..4f00b0ece 100644 --- a/templates/definition/vehicle/homeassistant.yaml +++ b/templates/definition/vehicle/homeassistant.yaml @@ -93,11 +93,11 @@ params: description: de: Service zum Laden starten en: Service to start charging - service: homeassistant/entities?uri={uri}&domain=script - example: "script.vehicle_start_charge" + service: homeassistant/entities?uri={uri}&domain=script,switch + example: "script.vehicle_start_charge; switch.vehicle_charger" help: - en: Entity ID for a script that starts charging the vehicle. Only useful with the [Vehicle API-only charger](https://docs.evcc.io/en/docs/devices/chargers#vehicle-api-only-charger). - de: Entitäts-ID für ein Skript zum Starten des Ladevorgangs. Nur sinnvoll mit der [Fahrzeug-API Ladesteuerung](https://docs.evcc.io/docs/devices/chargers#vehicle-api-only-charger). + en: Entity ID for a script or a switch that starts charging the vehicle. Only useful with the [Vehicle API-only charger](https://docs.evcc.io/en/docs/devices/chargers#vehicle-api-only-charger). If a switch is provided, Service to stop charging must be left empty. + de: Entitäts-ID für ein Skript oder einen Schalter zum Starten des Ladevorgangs. Nur sinnvoll mit der [Fahrzeug-API Ladesteuerung](https://docs.evcc.io/docs/devices/chargers#vehicle-api-only-charger). Wenn ein Schalter angegeben wird, muss der Service zum Stoppen des Ladens leer bleiben. - name: stop_charging description: de: Service zum Laden stoppen @@ -111,11 +111,11 @@ params: description: de: Service zum Aufwecken en: Service to wake up vehicle - service: homeassistant/entities?uri={uri}&domain=script - example: "script.vehicle_wakeup" + service: homeassistant/entities?uri={uri}&domain=script,button + example: "script.vehicle_wakeup; button.wakeup_vehicle" help: - en: Entity ID for a script that wakes up the vehicle - de: Entitäts-ID für ein Skript zum Aufwecken des Fahrzeugs + en: Entity ID for a script or a button that wakes up the vehicle + de: Entitäts-ID für ein Skript oder einen Schalter zum Aufwecken des Fahrzeugs - name: setMaxCurrent description: de: Ladestromstärke setzen [A] diff --git a/vehicle/homeassistant.go b/vehicle/homeassistant.go index 3b18ff6ea..e54a86614 100644 --- a/vehicle/homeassistant.go +++ b/vehicle/homeassistant.go @@ -2,6 +2,7 @@ package vehicle import ( "errors" + "strings" "time" "github.com/evcc-io/evcc/api" @@ -37,7 +38,7 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error FinishTime string // optional } Services struct { - Start string `mapstructure:"start_charging"` // script.* optional + Start string `mapstructure:"start_charging"` // script.* or switch.* optional Stop string `mapstructure:"stop_charging"` // script.* optional Wakeup string // script.* optional SetMaxCurrent string // number.* or input_number.* optional @@ -104,6 +105,8 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error } if cc.Services.Start != "" && cc.Services.Stop != "" { enable = func(enable bool) error { return res.enable(cc.Services.Start, cc.Services.Stop, enable) } + } else if strings.HasPrefix(cc.Services.Start, "switch") { + enable = func(enable bool) error { return conn.CallSwitchService(cc.Services.Start, enable) } } if cc.Services.Wakeup != "" { wakeup = func() error { return conn.CallSwitchService(cc.Services.Wakeup, true) }