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:
|
description:
|
||||||
de: Service zum Laden starten
|
de: Service zum Laden starten
|
||||||
en: Service to start charging
|
en: Service to start charging
|
||||||
service: homeassistant/entities?uri={uri}&domain=script
|
service: homeassistant/entities?uri={uri}&domain=script,switch
|
||||||
example: "script.vehicle_start_charge"
|
example: "script.vehicle_start_charge; switch.vehicle_charger"
|
||||||
help:
|
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).
|
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 zum Starten des Ladevorgangs. Nur sinnvoll mit der [Fahrzeug-API Ladesteuerung](https://docs.evcc.io/docs/devices/chargers#vehicle-api-only-charger).
|
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
|
- name: stop_charging
|
||||||
description:
|
description:
|
||||||
de: Service zum Laden stoppen
|
de: Service zum Laden stoppen
|
||||||
|
|
@ -111,11 +111,11 @@ params:
|
||||||
description:
|
description:
|
||||||
de: Service zum Aufwecken
|
de: Service zum Aufwecken
|
||||||
en: Service to wake up vehicle
|
en: Service to wake up vehicle
|
||||||
service: homeassistant/entities?uri={uri}&domain=script
|
service: homeassistant/entities?uri={uri}&domain=script,button
|
||||||
example: "script.vehicle_wakeup"
|
example: "script.vehicle_wakeup; button.wakeup_vehicle"
|
||||||
help:
|
help:
|
||||||
en: Entity ID for a script that wakes up the vehicle
|
en: Entity ID for a script or a button that wakes up the vehicle
|
||||||
de: Entitäts-ID für ein Skript zum Aufwecken des Fahrzeugs
|
de: Entitäts-ID für ein Skript oder einen Schalter zum Aufwecken des Fahrzeugs
|
||||||
- name: setMaxCurrent
|
- name: setMaxCurrent
|
||||||
description:
|
description:
|
||||||
de: Ladestromstärke setzen [A]
|
de: Ladestromstärke setzen [A]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package vehicle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/evcc-io/evcc/api"
|
"github.com/evcc-io/evcc/api"
|
||||||
|
|
@ -37,7 +38,7 @@ func NewHomeAssistantVehicleFromConfig(other map[string]any) (api.Vehicle, error
|
||||||
FinishTime string // optional
|
FinishTime string // optional
|
||||||
}
|
}
|
||||||
Services struct {
|
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
|
Stop string `mapstructure:"stop_charging"` // script.* optional
|
||||||
Wakeup string // script.* optional
|
Wakeup string // script.* optional
|
||||||
SetMaxCurrent string // number.* or input_number.* 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 != "" {
|
if cc.Services.Start != "" && cc.Services.Stop != "" {
|
||||||
enable = func(enable bool) error { return res.enable(cc.Services.Start, cc.Services.Stop, enable) }
|
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 != "" {
|
if cc.Services.Wakeup != "" {
|
||||||
wakeup = func() error { return conn.CallSwitchService(cc.Services.Wakeup, true) }
|
wakeup = func() error { return conn.CallSwitchService(cc.Services.Wakeup, true) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue