generated from rmcguire/go-server-with-otel
add ui, new config opts
This commit is contained in:
@@ -45,6 +45,10 @@ type Device struct {
|
||||
EnergyKWH float64
|
||||
EnergyType string // "KWH" or "KBTU"
|
||||
WaterGallons float64
|
||||
|
||||
// Raw is the undecoded equipment payload as received, kept for the web UI's
|
||||
// debug view (and to surface any fields we don't decode).
|
||||
Raw json.RawMessage
|
||||
}
|
||||
|
||||
// newDevice decodes an equipment block (the raw JSON map for one unit) into
|
||||
@@ -68,6 +72,9 @@ func newDevice(info map[string]json.RawMessage, now time.Time) *Device {
|
||||
d.Setpoint, d.SetpointMin, d.SetpointMax = setpoint(info["@SETPOINT"])
|
||||
d.Running, d.RunningState = running(info)
|
||||
d.modeEnumText = modeLabels(info)
|
||||
if b, err := json.Marshal(info); err == nil {
|
||||
d.Raw = b
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
@@ -228,6 +235,8 @@ func modeFromEnumText(s string) string {
|
||||
return "heat-pump"
|
||||
case "HIGH_DEMAND":
|
||||
return "high-demand"
|
||||
case "ELECTRIC_GAS":
|
||||
return "electric-gas"
|
||||
case "GAS":
|
||||
return "gas"
|
||||
case "PERFORMANCE":
|
||||
@@ -244,7 +253,7 @@ func modeFromEnumText(s string) string {
|
||||
// series regardless of which one is currently active.
|
||||
var KnownModes = []string{
|
||||
"off", "electric", "energy-saving", "heat-pump",
|
||||
"high-demand", "gas", "performance", "vacation", "unknown",
|
||||
"high-demand", "electric-gas", "gas", "performance", "vacation", "unknown",
|
||||
}
|
||||
|
||||
// running reports whether the unit is actively heating and a normalized label
|
||||
|
||||
Reference in New Issue
Block a user