Tronity: improve status detection (#12296)
This commit is contained in:
parent
ce29ae58a1
commit
878660d441
2 changed files with 19 additions and 12 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue