The fields the cloud sends, kept all the way to the card
Normalizing a provider's charger list threw most of the answer away: firmware, the site id, how the charger is registered, the charge power and the cloud's own OCPP reading all arrived from Anker and none of them got past providerCharger, which carried seven fields and dropped the rest. The information card could not show what it was never handed. It carries them now, and the card lays them out: firmware beside the model, site and site id where the charger lives, "Registered as" for standalone / in a system / bound, and — when the service knows — state, charge power and OCPP status. Charge power is relayed exactly as worded upstream, since the unit is theirs and putting one on it here would be inventing it. Settings' own list gains the firmware in its subtitle. A field no view supplied still leaves no row, so an account whose chargers stand outside a system reads shorter rather than emptier. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
86ea97b414
commit
ad785ee9f8
@@ -69,10 +69,24 @@ type providerCharger struct {
|
||||
Name string `json:"name"`
|
||||
Vendor string `json:"vendor,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
Firmware string `json:"firmware,omitempty"`
|
||||
SiteID string `json:"siteId,omitempty"`
|
||||
SiteName string `json:"siteName,omitempty"`
|
||||
Status string `json:"status,omitempty"` // the service's own word for its state
|
||||
Online *bool `json:"online,omitempty"`
|
||||
|
||||
// How the charger is registered on the account — standalone, inside a
|
||||
// system (site), or merely bound to it. A charger can be several at once,
|
||||
// and which ones it is decides how much the service says about it.
|
||||
Sources []string `json:"sources,omitempty"`
|
||||
|
||||
// What it is doing right now, when the service knows: the charge power as
|
||||
// the service words it (the unit is upstream's, so it is relayed verbatim)
|
||||
// and the charger's OCPP connector state as the service sees it.
|
||||
Power string `json:"power,omitempty"`
|
||||
OcppStatus *int `json:"ocppStatus,omitempty"`
|
||||
OcppStatusDesc string `json:"ocppStatusDesc,omitempty"`
|
||||
|
||||
// LinkedChargerID is set when this one is already in DriverVault, so the UI
|
||||
// never offers to import the same charger twice.
|
||||
LinkedChargerID string `json:"linkedChargerId,omitempty"`
|
||||
@@ -105,12 +119,18 @@ func (ankerChargerSource) gate(ctx context.Context, s *Server, who *callerIdenti
|
||||
func (ankerChargerSource) chargers(raw json.RawMessage) []providerCharger {
|
||||
var env struct {
|
||||
Chargers []struct {
|
||||
SN string `json:"sn"`
|
||||
Name string `json:"name"`
|
||||
Model string `json:"model"`
|
||||
SiteName string `json:"siteName"`
|
||||
StatusDesc string `json:"statusDesc"`
|
||||
Online *bool `json:"online"`
|
||||
SN string `json:"sn"`
|
||||
Name string `json:"name"`
|
||||
Model string `json:"model"`
|
||||
Firmware string `json:"firmware"`
|
||||
SiteID string `json:"siteId"`
|
||||
SiteName string `json:"siteName"`
|
||||
Sources []string `json:"sources"`
|
||||
StatusDesc string `json:"statusDesc"`
|
||||
Online *bool `json:"online"`
|
||||
Power string `json:"power"`
|
||||
OcppStatus *int `json:"ocppStatus"`
|
||||
OcppStatusDesc string `json:"ocppStatusDesc"`
|
||||
} `json:"chargers"`
|
||||
}
|
||||
if json.Unmarshal(raw, &env) != nil {
|
||||
@@ -123,7 +143,9 @@ func (ankerChargerSource) chargers(raw json.RawMessage) []providerCharger {
|
||||
}
|
||||
out = append(out, providerCharger{
|
||||
ID: c.SN, Name: c.Name, Vendor: "Anker Solix", Model: c.Model,
|
||||
SiteName: c.SiteName, Status: c.StatusDesc, Online: c.Online,
|
||||
Firmware: c.Firmware, SiteID: c.SiteID, SiteName: c.SiteName,
|
||||
Sources: c.Sources, Status: c.StatusDesc, Online: c.Online,
|
||||
Power: c.Power, OcppStatus: c.OcppStatus, OcppStatusDesc: c.OcppStatusDesc,
|
||||
})
|
||||
}
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user