Home Assistant: allow switch for enable/disable (#28260)
Some checks failed
Some checks failed
This commit is contained in:
parent
385296f63a
commit
340f94087c
2 changed files with 12 additions and 9 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue