Tronity: improve status detection (#12296)

This commit is contained in:
andig 2024-02-16 16:07:59 +01:00 • committed by GitHub
parent ce29ae58a1
commit 878660d441
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 12 deletions

View file

@ -193,14 +193,18 @@ func (v *Tronity) Soc() (float64, error) {
func (v *Tronity) status() (api.ChargeStatus, error) {
status := api.StatusA // disconnected
res, err := v.bulkG()
if err == nil {
if res.Charging == "Charging" {
status = api.StatusC
}
if err != nil {
return status, err
}
return status, err
switch {
case res.Charging == "Charging":
status = api.StatusC
case res.Plugged:
status = api.StatusB
}
return status, nil
}
var _ api.VehicleRange = (*Tronity)(nil)

View file

@ -4,7 +4,9 @@ package tronity
const (
ReadCharge = "tronity_charging" // Know whether vehicle is charging
ReadLocation = "tronity_location" // Last known location
ReadOdometer = "tronity_odometer" // Retrieve total distance traveled
ReadRange = "tronity_range" // Last known range information
WriteChargeStartStop = "tronity_control_charging"
)
@ -21,12 +23,13 @@ type Vehicle struct {
}
type Bulk struct {
Odometer float64
Range float64
Level float64
Charging string // Charging
// Latitude float64/string
// Longitude float64/string
Odometer float64
Range float64
Level float64
Charging string
Plugged bool
Latitude float64
Longitude float64
Timestamp int64
}