A field we have no name for is still a field it sent
Two cards on the Charging page were answering with a fraction of what the charger and the account actually report, and in both the losses happened quietly, in a parse that kept the fields it recognised and dropped the rest on the floor. Charger information asked three account-wide views and kept fourteen fields. A charger registered on its own is absent from the site view, which is the only one of the three carrying state, charge power and OCPP status — so exactly the charger that stands alone got the column of dashes, and nothing said why. The per-charger station record, get_evcharger_station_info, is what the mobile app opens when you tap a charger, and it is the one view that answers for a charger outside a station; it is now the fourth view, asked per charger, a failure there costing that charger's row and no more. Alongside it, every field each of the four views sent is kept as attrs, under the cloud's own key, nested objects joined with a dot and arrays carrying their index. First view to answer a key wins, which is the rule the named fields already merged by. Two hundred keys and two hundred and forty runes per value keep a station record with a session list from becoming the whole card. Charger readings lost data twice over. The frame decoder skipped any field byte its per-message map could not name, and a message type with no map decoded to nothing at all; those fields are now kept under the message and the byte they arrived in — 0410.c9 — decoded but unscaled, because a factor is half of a meaning and we do not have the other half. Then the projection read forty-odd names into typed fields and dropped the remainder: sessionStartedAt, the per-phase session energies, the three touch modes, the load-balance monitor and its meter flag, the solar monitor. Those land in extra, and the list maintains itself — the four accessors note every key they read, extra is what is left, and a field modelled later stops appearing there without anyone remembering to remove it. Keeping unnamed fields had one consequence worth guarding. An unmapped message now decodes to something rather than nothing, and ingest stamped settingsAt for anything that was not telemetry — the timestamp a control command waits on to say the charger acknowledged it. A frame we cannot read is not an acknowledgement, so the stamp is now conditional on the message type being one we map, while its fields are kept either way. Both cards show the remainder as what it is: the service's own key, no unit, no translation, no renaming, under a heading that says whose words these are. The blocks appear only when there is something in them, so a Modbus charger's readings card and a charger the cloud says nothing more about are unchanged. Naming one of these fields is a later commit, made from evidence; inventing a label for it today would only make a guess look settled. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1dc20461de
commit
2425a8d3d6
@@ -87,6 +87,12 @@ type providerCharger struct {
|
||||
OcppStatus *int `json:"ocppStatus,omitempty"`
|
||||
OcppStatusDesc string `json:"ocppStatusDesc,omitempty"`
|
||||
|
||||
// Attrs is everything else the service said about this charger, under the
|
||||
// service's own field names. The fields above are the ones DriverVault has a
|
||||
// name for; this is the remainder, relayed so a card can show what the
|
||||
// account actually knows rather than only the part we modelled.
|
||||
Attrs map[string]string `json:"attrs,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"`
|
||||
@@ -131,6 +137,8 @@ func (ankerChargerSource) chargers(raw json.RawMessage) []providerCharger {
|
||||
Power string `json:"power"`
|
||||
OcppStatus *int `json:"ocppStatus"`
|
||||
OcppStatusDesc string `json:"ocppStatusDesc"`
|
||||
|
||||
Attrs map[string]string `json:"attrs"`
|
||||
} `json:"chargers"`
|
||||
}
|
||||
if json.Unmarshal(raw, &env) != nil {
|
||||
@@ -146,6 +154,7 @@ func (ankerChargerSource) chargers(raw json.RawMessage) []providerCharger {
|
||||
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,
|
||||
Attrs: c.Attrs,
|
||||
})
|
||||
}
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user