3 Commits
Author SHA1 Message Date
rmcguire 47073a263a upgrades
Build and Publish / check-chart (push) Successful in 2m5s
Build and Publish / helm-release (push) Skipped
Build and Publish / go-binaries (push) Successful in 5m31s
Build and Publish / container-images (push) Successful in 9m44s
2026-09-07 11:09:17 -04:00
rmcguire 516eccec0c update CHANGELOG
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / go-binaries (push) Successful in 2m5s
Build and Publish / container-images (push) Successful in 2m14s
2026-07-16 16:34:32 -04:00
rmcguire df01e060e4 add ui, new config opts 2026-07-16 16:32:44 -04:00
35 changed files with 1239 additions and 76 deletions
+28
View File
@@ -45,6 +45,26 @@ Exporter for Rheem EcoNet / Rheemcloud water heaters, built on the
`list_water_heaters` tool delegating to the gRPC server. Kept in place as a
fallback. **Switch between the two** with the aliased `econetmcp` import in
`pkg/econet/econet.go` (one line — both packages export identical symbols).
- `pkg/econet/econetui/` — admin UI served at **`/`** (the root; the HTTP
server is not "under `/api`" — only the grpc-gateway is, via
`grpcGatewayPath`). Gated by `enableWebUI` (default true). Server-rendered
`html/template` + embedded assets (`embed.FS`: Pico.css classless, HTMX,
per-`generic_type` SVG icons) with a dark-mode toggle (persisted in
`localStorage`). Reads devices and writes mode through the in-process gRPC
server, same as the MCP packages. Routes: `GET /` (page), `GET /ui/devices`
(HTMX poll partial, every 30s), `POST /ui/devices/{serial}/mode` (returns a
re-rendered card), `GET /ui/devices/{serial}/debug` (raw device JSON for the
🐛 modal), `GET /static/`. A **fill-level meter** visualizes hot-water
availability. `iconFor` matches `@TYPE` loosely (substring, case/spacing
insensitive) since real values vary (e.g. `heatpumpWaterHeaterGen5`).
Template funcs (`fillClass`/`fillWidth`) take **int32** to match proto fields
`html/template` is strict about arg types.
**Pending state** for a mode change is best-effort: `pending.go` holds a
TTL-bounded (`pendingTTL`, 90s) desired-mode hint, shown as an "Updating…"
badge and cleared once the reported mode converges; a full page load ignores
it (fresh reported state), the poll honors it. **Auth is left to the edge**
(oauth2-proxy) — the UI/write live at `/` and `/ui/`; keep `/health` and
`/metrics` on skip-auth so probes/Prometheus keep working.
- `pkg/econet/econetmetrics/` — OTEL observable gauges (read the client
snapshot at scrape time; no poller of its own).
@@ -60,6 +80,14 @@ that's all it takes — no extra wiring.
- `costPerKWH` is **US dollars per kWh** (0.18 = 18¢), feeding
`econet_energy_cost_dollars`.
- **The `default:` tag is NOT applied at runtime for custom `ServiceConfig`
fields** — `LoadEnv` uses plain `env.Parse` (no `DefaultValueTagName`), so
`default:` only feeds the JSON schema. A bool that must default to true
therefore can't be a plain `bool` (zero value = false); `enableWebUI` is a
`*bool` where nil ⇒ enabled (read via `WebUIEnabled()`). `disableWaterUsage`
is a plain `bool` because its desired default (poll water usage) is the zero
value — set it true to skip the wasted water-usage REST call on units that
don't report it.
- `econetTLSInsecure` (env `ECONET_TLS_INSECURE`) skips TLS certificate
verification when connecting to the EcoNet cloud API. It exists because the
upstream host (cloudblade) serves a
+26
View File
@@ -6,6 +6,32 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [v0.5.0] - 2026-07-16
### Added
* **Admin UI** at `/` (`econetui`): a server-rendered dashboard of devices and
their status (connectivity, running state, setpoint, hot-water, alerts) with a
per-device mode dropdown that writes via the in-process gRPC server. HTMX for
interactivity (30s auto-refresh, card-level swaps), Pico.css + embedded SVG
icons per device type, a hot-water **fill-level meter**, a 🐛 debug button
that shows the raw device JSON, and a persisted **dark-mode toggle** — all
served from a single binary via `embed.FS`, responsive down to mobile. Mode
changes show a best-effort, TTL-bounded "Updating…" pending badge that
reconciles against the reported state (or falls back to a fresh fetch if it
never lands). Auth is intentionally left to the edge (e.g. oauth2-proxy);
`/health` and `/metrics` stay unauthenticated.
* `enableWebUI` config (env `ECONET_ENABLE_WEB_UI`, default **true**) to toggle
the admin UI, and `disableWaterUsage` (env `ECONET_DISABLE_WATER_USAGE`,
default false) to skip the per-device water-usage REST call on units that
don't report it.
* `MODE_ELECTRIC_GAS` added to the `Mode` enum — real devices report a combined
"Electric/Gas" mode that was previously decoded as unknown and dropped from
the settable-mode list.
* `supported_modes` on the `Device` proto message (the settable modes for that
unit), populated from the device's reported mode list and surfaced over gRPC,
REST, and MCP.
## [v0.4.0] - 2026-07-16
### Added
+33 -19
View File
@@ -40,6 +40,7 @@ const (
Mode_MODE_GAS Mode = 6
Mode_MODE_PERFORMANCE Mode = 7
Mode_MODE_VACATION Mode = 8
Mode_MODE_ELECTRIC_GAS Mode = 9 // combined electric/gas backup mode (e.g. hybrid units)
)
// Enum value maps for Mode.
@@ -54,6 +55,7 @@ var (
6: "MODE_GAS",
7: "MODE_PERFORMANCE",
8: "MODE_VACATION",
9: "MODE_ELECTRIC_GAS",
}
Mode_value = map[string]int32{
"MODE_UNSPECIFIED": 0,
@@ -65,6 +67,7 @@ var (
"MODE_GAS": 6,
"MODE_PERFORMANCE": 7,
"MODE_VACATION": 8,
"MODE_ELECTRIC_GAS": 9,
}
)
@@ -117,6 +120,7 @@ type Device struct {
AlertCount int32 `protobuf:"varint,16,opt,name=alert_count,json=alertCount,proto3" json:"alert_count,omitempty"`
Away bool `protobuf:"varint,17,opt,name=away,proto3" json:"away,omitempty"`
LastUpdated *timestamppb.Timestamp `protobuf:"bytes,18,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"`
SupportedModes []Mode `protobuf:"varint,19,rep,packed,name=supported_modes,json=supportedModes,proto3,enum=econet.v1alpha1.Mode" json:"supported_modes,omitempty"` // modes this device can be set to (may be empty)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -277,6 +281,13 @@ func (x *Device) GetLastUpdated() *timestamppb.Timestamp {
return nil
}
func (x *Device) GetSupportedModes() []Mode {
if x != nil {
return x.SupportedModes
}
return nil
}
type ListDevicesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -547,7 +558,7 @@ var File_econet_v1alpha1_econet_proto protoreflect.FileDescriptor
const file_econet_v1alpha1_econet_proto_rawDesc = "" +
"\n" +
"\x1ceconet/v1alpha1/econet.proto\x12\x0feconet.v1alpha1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xde\x04\n" +
"\x1ceconet/v1alpha1/econet.proto\x12\x0feconet.v1alpha1\x1a\x1bbuf/validate/validate.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x9e\x05\n" +
"\x06Device\x12#\n" +
"\rserial_number\x18\x01 \x01(\tR\fserialNumber\x12\x1b\n" +
"\tdevice_id\x18\x02 \x01(\tR\bdeviceId\x12#\n" +
@@ -569,7 +580,8 @@ const file_econet_v1alpha1_econet_proto_rawDesc = "" +
"\valert_count\x18\x10 \x01(\x05R\n" +
"alertCount\x12\x12\n" +
"\x04away\x18\x11 \x01(\bR\x04away\x12=\n" +
"\flast_updated\x18\x12 \x01(\v2\x1a.google.protobuf.TimestampR\vlastUpdated\"\x14\n" +
"\flast_updated\x18\x12 \x01(\v2\x1a.google.protobuf.TimestampR\vlastUpdated\x12>\n" +
"\x0fsupported_modes\x18\x13 \x03(\x0e2\x15.econet.v1alpha1.ModeR\x0esupportedModes\"\x14\n" +
"\x12ListDevicesRequest\"H\n" +
"\x13ListDevicesResponse\x121\n" +
"\adevices\x18\x01 \x03(\v2\x17.econet.v1alpha1.DeviceR\adevices\"@\n" +
@@ -582,7 +594,7 @@ const file_econet_v1alpha1_econet_proto_rawDesc = "" +
"\x04mode\x18\x02 \x01(\x0e2\x15.econet.v1alpha1.ModeB\n" +
"\xbaH\a\x82\x01\x04\x10\x01 \x00R\x04mode\"B\n" +
"\x0fSetModeResponse\x12/\n" +
"\x06device\x18\x01 \x01(\v2\x17.econet.v1alpha1.DeviceR\x06device*\xb6\x01\n" +
"\x06device\x18\x01 \x01(\v2\x17.econet.v1alpha1.DeviceR\x06device*\xcd\x01\n" +
"\x04Mode\x12\x14\n" +
"\x10MODE_UNSPECIFIED\x10\x00\x12\f\n" +
"\bMODE_OFF\x10\x01\x12\x11\n" +
@@ -592,7 +604,8 @@ const file_econet_v1alpha1_econet_proto_rawDesc = "" +
"\x10MODE_HIGH_DEMAND\x10\x05\x12\f\n" +
"\bMODE_GAS\x10\x06\x12\x14\n" +
"\x10MODE_PERFORMANCE\x10\a\x12\x11\n" +
"\rMODE_VACATION\x10\b2\x84\x03\n" +
"\rMODE_VACATION\x10\b\x12\x15\n" +
"\x11MODE_ELECTRIC_GAS\x10\t2\x84\x03\n" +
"\rEconetService\x12s\n" +
"\vListDevices\x12#.econet.v1alpha1.ListDevicesRequest\x1a$.econet.v1alpha1.ListDevicesResponse\"\x19\x82\xd3\xe4\x93\x02\x13\x12\x11/v1alpha1/devices\x12}\n" +
"\tGetDevice\x12!.econet.v1alpha1.GetDeviceRequest\x1a\".econet.v1alpha1.GetDeviceResponse\")\x82\xd3\xe4\x93\x02#\x12!/v1alpha1/devices/{serial_number}\x12\x7f\n" +
@@ -626,21 +639,22 @@ var file_econet_v1alpha1_econet_proto_goTypes = []any{
}
var file_econet_v1alpha1_econet_proto_depIdxs = []int32{
8, // 0: econet.v1alpha1.Device.last_updated:type_name -> google.protobuf.Timestamp
1, // 1: econet.v1alpha1.ListDevicesResponse.devices:type_name -> econet.v1alpha1.Device
1, // 2: econet.v1alpha1.GetDeviceResponse.device:type_name -> econet.v1alpha1.Device
0, // 3: econet.v1alpha1.SetModeRequest.mode:type_name -> econet.v1alpha1.Mode
1, // 4: econet.v1alpha1.SetModeResponse.device:type_name -> econet.v1alpha1.Device
2, // 5: econet.v1alpha1.EconetService.ListDevices:input_type -> econet.v1alpha1.ListDevicesRequest
4, // 6: econet.v1alpha1.EconetService.GetDevice:input_type -> econet.v1alpha1.GetDeviceRequest
6, // 7: econet.v1alpha1.EconetService.SetMode:input_type -> econet.v1alpha1.SetModeRequest
3, // 8: econet.v1alpha1.EconetService.ListDevices:output_type -> econet.v1alpha1.ListDevicesResponse
5, // 9: econet.v1alpha1.EconetService.GetDevice:output_type -> econet.v1alpha1.GetDeviceResponse
7, // 10: econet.v1alpha1.EconetService.SetMode:output_type -> econet.v1alpha1.SetModeResponse
8, // [8:11] is the sub-list for method output_type
5, // [5:8] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
0, // 1: econet.v1alpha1.Device.supported_modes:type_name -> econet.v1alpha1.Mode
1, // 2: econet.v1alpha1.ListDevicesResponse.devices:type_name -> econet.v1alpha1.Device
1, // 3: econet.v1alpha1.GetDeviceResponse.device:type_name -> econet.v1alpha1.Device
0, // 4: econet.v1alpha1.SetModeRequest.mode:type_name -> econet.v1alpha1.Mode
1, // 5: econet.v1alpha1.SetModeResponse.device:type_name -> econet.v1alpha1.Device
2, // 6: econet.v1alpha1.EconetService.ListDevices:input_type -> econet.v1alpha1.ListDevicesRequest
4, // 7: econet.v1alpha1.EconetService.GetDevice:input_type -> econet.v1alpha1.GetDeviceRequest
6, // 8: econet.v1alpha1.EconetService.SetMode:input_type -> econet.v1alpha1.SetModeRequest
3, // 9: econet.v1alpha1.EconetService.ListDevices:output_type -> econet.v1alpha1.ListDevicesResponse
5, // 10: econet.v1alpha1.EconetService.GetDevice:output_type -> econet.v1alpha1.GetDeviceResponse
7, // 11: econet.v1alpha1.EconetService.SetMode:output_type -> econet.v1alpha1.SetModeResponse
9, // [9:12] is the sub-list for method output_type
6, // [6:9] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_econet_v1alpha1_econet_proto_init() }
File diff suppressed because one or more lines are too long
+1
View File
@@ -5,6 +5,7 @@
econetEmail: ""
costPerKWH: 0.0 # US dollars per kWh (e.g. 0.18 = 18 cents), not cents
pollInterval: 1m # how often device state + daily usage are re-fetched over REST
enableWebUI: true # serve the admin UI at / (default true; set false to disable)
# go-app config
name: econet-exporter
+10 -2
View File
@@ -213,6 +213,13 @@
"lastUpdated": {
"type": "string",
"format": "date-time"
},
"supportedModes": {
"type": "array",
"items": {
"$ref": "#/definitions/v1alpha1Mode"
},
"title": "modes this device can be set to (may be empty)"
}
},
"description": "Device is the live state of a single Rheem EcoNet device\n(typically a water heater) as reported by the Rheem cloud."
@@ -248,10 +255,11 @@
"MODE_HIGH_DEMAND",
"MODE_GAS",
"MODE_PERFORMANCE",
"MODE_VACATION"
"MODE_VACATION",
"MODE_ELECTRIC_GAS"
],
"default": "MODE_UNSPECIFIED",
"description": "Mode is a settable operating mode for a water heater. The values mirror the\nkebab-case slugs reported in Device.mode. Not every device supports every\nmode; the supported set is device-specific (derived from the unit's reported\nmode list), so SetMode validates against the target device."
"description": "Mode is a settable operating mode for a water heater. The values mirror the\nkebab-case slugs reported in Device.mode. Not every device supports every\nmode; the supported set is device-specific (derived from the unit's reported\nmode list), so SetMode validates against the target device.\n\n - MODE_ELECTRIC_GAS: combined electric/gas backup mode (e.g. hybrid units)"
},
"v1alpha1SetModeResponse": {
"type": "object",
+11
View File
@@ -127,6 +127,10 @@
"default": 0.19,
"type": "number"
},
"disableWaterUsage": {
"default": false,
"type": "boolean"
},
"econetEmail": {
"type": "string"
},
@@ -137,6 +141,13 @@
"default": false,
"type": "boolean"
},
"enableWebUI": {
"default": true,
"type": [
"null",
"boolean"
]
},
"environment": {
"type": "string"
},
+1
View File
@@ -9,6 +9,7 @@ ECONET_EMAIL="[email protected]"
ECONET_PASSWORD="changeme"
ECONET_COST_PER_KWH=0.12 ## US dollars per kWh (0.12 = 12 cents), for econet_energy_cost_dollars
ECONET_USAGE_INTERVAL=5m ## how often to poll energy/water usage history
ECONET_ENABLE_WEB_UI=true ## serve the admin UI at / (default true; set false to disable)
# App OTEL Config
APP_OTEL_STDOUT_ENABLED=true ## For testing only
+42 -39
View File
@@ -3,76 +3,79 @@ module gitea.libretechconsulting.com/rmcguire/econet-exporter
go 1.26.1
require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2
connectrpc.com/connect v1.20.0
gitea.libretechconsulting.com/rmcguire/go-app v0.17.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0
github.com/modelcontextprotocol/go-sdk v1.6.1
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260709214304-372b2d56e470
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0
github.com/modelcontextprotocol/go-sdk v1.7.0
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260729122341-6334690a62b6
github.com/rs/zerolog v1.35.1
go.opentelemetry.io/otel/metric v1.44.0
go.opentelemetry.io/otel/trace v1.44.0
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7
google.golang.org/grpc v1.82.0
google.golang.org/protobuf v1.36.11
go.opentelemetry.io/otel/metric v1.46.0
go.opentelemetry.io/otel/trace v1.46.0
google.golang.org/genproto/googleapis/api v0.0.0-20260904194346-d0f1323225a4
google.golang.org/grpc v1.83.2
google.golang.org/protobuf v1.36.12
k8s.io/utils v0.0.0-20260626114624-be93311217bd
)
require (
github.com/caarlos0/env/v11 v11.4.1
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.4 // indirect
github.com/swaggest/jsonschema-go v0.3.79 // indirect
github.com/swaggest/refl v1.4.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.69.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
go.opentelemetry.io/otel v1.44.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.66.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.71.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 // indirect
go.opentelemetry.io/otel v1.46.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.68.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0 // indirect
go.opentelemetry.io/otel/sdk v1.46.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.46.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
require (
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.34.2-20240917150400-3f349e63f44a.2 // indirect
buf.build/go/protovalidate v1.2.0 // indirect
cel.dev/expr v0.25.2 // indirect
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.36.12-20260323171043-6e06f84ad823.2 // indirect
buf.build/go/protovalidate v1.4.0 // indirect
cel.dev/cel-go v0.32.0 // indirect
cel.dev/expr v0.25.3 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/cel-go v0.29.1 // indirect
github.com/google/cel-go v0.31.0 // indirect
github.com/google/jsonschema-go v0.4.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.69.0 // indirect
github.com/prometheus/client_golang v1.24.1 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.71.0 // indirect
github.com/prometheus/otlptranslator v1.0.0 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
github.com/redpanda-data/common-go/api v0.0.0-20250801174835-9eea07f1ea06 // indirect
github.com/prometheus/procfs v0.22.0 // indirect
github.com/redpanda-data/common-go/api v0.0.0-20260805234448-c124c21fdb6b // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/segmentio/encoding v0.5.4 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 // indirect
golang.org/x/net v0.56.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/exp v0.0.0-20260824195058-e88cd73687aa // indirect
golang.org/x/net v0.58.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/text v0.38.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.41.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260904194346-d0f1323225a4 // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect
)
+88
View File
@@ -1,11 +1,21 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1 h1:s6hzCXtND/ICdGPTMGk7C+/BFlr2Jg5GyH0NKf4XGXg=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20260415201107-50325440f8f2.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2 h1:NbnlmV26O7oZ1iM5tsCI+GEx+3ZSdrhvnKQ/eWSrLiY=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.2/go.mod h1:TCt1lluMFnctISJXvkIQ4x3ABrPuUKCWKyjKdkJNBpw=
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.34.2-20240917150400-3f349e63f44a.2 h1:JyGBchZNUPlQ7/qjieeKq/Cy+/i1vc0H+cIniGZNSFg=
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.34.2-20240917150400-3f349e63f44a.2/go.mod h1:wThyg02xJx4K/DA5fg0QlKts8XVPyTT86JC8hPfEzno=
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.36.12-20260323171043-6e06f84ad823.2 h1:xjcABVeom3bb6595kMf8M3wKHyBE8XAvW87h2itjj1Q=
buf.build/gen/go/redpandadata/common/protocolbuffers/go v1.36.12-20260323171043-6e06f84ad823.2/go.mod h1:1O+pTOUPSosYIhh9BbmQqfL455/rzSEtTjGyrZiDKdc=
buf.build/go/protovalidate v1.2.0 h1:DQVrUWkmGTBij+kOYv/x2LLxwcLaGKMdzShj1/6/3H0=
buf.build/go/protovalidate v1.2.0/go.mod h1:7rYiQEhqvAipoazpVNBBH2S2f8bjG4huMVy1V2Yofn4=
buf.build/go/protovalidate v1.4.0 h1:UjLrYbt5VX7+TMOs2+pG5FhZhIG1mSfK4EIopbb4LcM=
buf.build/go/protovalidate v1.4.0/go.mod h1:8vJfzNT6NIG2qm3uFsJDXMlRmG+bQJzbcIn1Aa0vPGs=
cel.dev/cel-go v0.32.0 h1:irvpFKr5EuGPyxeME03ERh0rii1TX+BDAnB9eL3IvNk=
cel.dev/cel-go v0.32.0/go.mod h1:DnVip7tpJSsgZymwfT+m1tnEVy3ivAjSMXPx12YrMkU=
cel.dev/expr v0.25.2 h1:K6j46C81hXtZQfuX60cVWQFBJahKSE2gfRbNuvr5bFs=
cel.dev/expr v0.25.2/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
cel.dev/expr v0.25.3 h1:A2jO8jwOugrrovveCWfj0KEZOfqiLgAcwjpHPhzIGw0=
cel.dev/expr v0.25.3/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4=
connectrpc.com/connect v1.20.0 h1:6TNDAB+WeNd2uolWNlYczB5E0KNNaVMNUEx8JEUsPmQ=
connectrpc.com/connect v1.20.0/go.mod h1:A2ygJrukXwWy32vkCAAHNVguZrqZ+jeZ9rGRnGR4dN4=
gitea.libretechconsulting.com/rmcguire/go-app v0.17.1 h1:OdUNAXRoDpB5sC3KdaJC7Rav8MmxiRZC0fRx9YNH1Ks=
@@ -33,6 +43,8 @@ github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
@@ -41,6 +53,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/cel-go v0.29.1 h1:8Gx3S5HPop5XPOHtZI8vkaGk+DBW/nn9fkpNPbh5dBk=
github.com/google/cel-go v0.29.1/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
github.com/google/cel-go v0.31.0 h1:H0bhpFTqOvmHrBGrWKp7ZlhBm5Hh8PYUEXnwxT1LL7A=
github.com/google/cel-go v0.31.0/go.mod h1:X0bD6iVNR8pkROSOoHVdgTkzmRcosof7WQqCD6wcMc8=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0=
@@ -49,12 +63,17 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 h1:B+8ClL/kCQkRiU82d9xajRPKYMrB7E0MbtzWVi1K4ns=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3/go.mod h1:NbCUVmiS4foBGBHOYlCT25+YmGpJ32dZPi75pGEUpj4=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.4 h1:9ZJYjPEJpcleIKcqysXOo14NLQYwu23fzmKRFpIjPjc=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.4/go.mod h1:0xydIeg2omQ9DH6zYMP24Kk57793rnLUvP8fwdbFvz8=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 h1:/Tnpcb2E0Pz/tN9s3bfEY2Q8ePCEX9iuS+cneUwncnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0/go.mod h1:zOBXOsUaBSjKgmH4OGzV1esUpR3oUSCPYVd2cUBjKYY=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -65,8 +84,12 @@ github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
github.com/modelcontextprotocol/go-sdk v1.6.1 h1:0zOSupjKUxPKSocPT1Wtago+mUHU2/uZ4xSOY0FGReU=
github.com/modelcontextprotocol/go-sdk v1.6.1/go.mod h1:kzm3kzFL1/+AziGOE0nUs3gvPoNxMCvkxokMkuFapXQ=
github.com/modelcontextprotocol/go-sdk v1.7.0 h1:yqjY2dsbKAC0LSuWZVBMrHgiG8ukXv6NRo0JiALay44=
github.com/modelcontextprotocol/go-sdk v1.7.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
@@ -75,18 +98,30 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk=
github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y=
github.com/prometheus/common v0.71.0 h1:9KDAKb7Mj3HEVKyFCK6Dc/HIwlBzZIN2l7/lrHl3KK8=
github.com/prometheus/common v0.71.0/go.mod h1:CLJ5H8TEsGX8bl31BdMkfhIZ+QmZ9tBPPotUxUbfcmk=
github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos=
github.com/prometheus/otlptranslator v1.0.0/go.mod h1:vRYWnXvI6aWGpsdY/mOT/cbeVRBlPWtBNDb7kGR3uKM=
github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/prometheus/procfs v0.22.0 h1:6q9+/JL9IKAPbCmBrv9n5O5Ty3NKnciV5X7YGw0oics=
github.com/prometheus/procfs v0.22.0/go.mod h1:CvmFr/GVhIjIvWJZW3tgkODBQMRIf0EyWMQLHCHab58=
github.com/redpanda-data/common-go/api v0.0.0-20250801174835-9eea07f1ea06 h1:9Ecc+Cg1EyqSTIQ6wQKoKk8BqDlBQmR74bJui4qIqsM=
github.com/redpanda-data/common-go/api v0.0.0-20250801174835-9eea07f1ea06/go.mod h1:klAmWfc8Q3hEZk8geFTMu6f2sk3VUKRS7cv/LvB05ig=
github.com/redpanda-data/common-go/api v0.0.0-20260805234448-c124c21fdb6b h1:37u906bF7SsdlHuFwkDjFY/NAe6vKkMJUMdGNB9FBdY=
github.com/redpanda-data/common-go/api v0.0.0-20260805234448-c124c21fdb6b/go.mod h1:X4iTnBNz6LJ7KwyOkW/7xh+pBS8tuqFWUwECPkVDjIo=
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260709214304-372b2d56e470 h1:gBvQBXc+MtBa8aGjXTOFLPu+1a+7I0UMu6Np9ofY1Ow=
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260709214304-372b2d56e470/go.mod h1:1Ulz0OS7NpChjyMu6NWZucui6SEbIsOzAshGfpqWCV8=
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260729122341-6334690a62b6 h1:ThmYtRYkopbcf1vhKlsE6OEMQWHl1VrIxk9ZgLqJpgw=
github.com/redpanda-data/protoc-gen-go-mcp v0.0.0-20260729122341-6334690a62b6/go.mod h1:qCv9zvs6wyK9+EyY0auYApUdOEgi6TVM6aWQ7Byahuc=
github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8=
github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWgejz1AlYpY1mI0=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
@@ -103,6 +138,7 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ=
github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU=
github.com/swaggest/jsonschema-go v0.3.79 h1:0TOShCbAJ9Xjt1e2W83l+QtMQSG2pbun2EkiYTyafCs=
@@ -119,64 +155,116 @@ go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.69.0 h1:2yEATaop1/a1I4psnSLgWVPLWwCzkqWakgJy7xTDVy0=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.69.0/go.mod h1:D7J12YRapIekYyPWgGPlA/23pRmpSEZC5xJC/TTLI9U=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.71.0 h1:B2h3uqicet1CT2N5TOFhS+Gq++9i0/CLmaxvhmhtP5s=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.71.0/go.mod h1:dylvB+ZiiwMvsDij9O84Uy7SijLgHMX4mbkncds+4Sw=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 h1:8tvICD4vSTOOsNrsI4Ljf6C+6UKvpTEH5XY3JMoyPoo=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0/go.mod h1:z9+yiacE0IHRqM4qFfkbt/JYlmYXgss8GY/jXoNuPJI=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU=
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0 h1:SUplec5dp06reu1zaXmOXdvqH398taqrDXqUl99jxSc=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.44.0/go.mod h1:ho2g4N+ane+swq5I/VBkKWnRDY4kUINH3FuqyZqX/Ug=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0 h1:qkDYCAFiZXLcs1L4aY+tP2wguQ4kURANqHOQMA2et2s=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.46.0/go.mod h1:tkipS4DRzmpAmvg+Gw4++O1IdDq6TVDnvnYU6cmbQVs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0 h1:4YsVu3B8+3qtWYYrsUYgn0OG78pN0rnNPRGX4SbokQI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.44.0/go.mod h1:+wnlSn0mD1ADVMe3v9Z/WIaiz6q6gL2J/ejaAmdmv80=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0 h1:OFnwLJr+pF3iHrlGSzbxyuo6/6HyBlnlN1CWEJmBVcw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.46.0/go.mod h1:716wFneO0ov19A2beH5hjfh9AK5z/VWNAtDijp1Y0/g=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0 h1:qazEJlUOQzhCpzQpFETGby7EdqjI1wsd0W+6Gg1SCTU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.44.0/go.mod h1:fOD2Yefuxixkx3ahVNf0O/PERb6r4OlbxfATVnYvzCo=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0 h1:w53CDeOA/Kurp7yRsegSr6pbbr759dOvJ+yNmWM6Hxs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.46.0/go.mod h1:BOmGMCbAtvcJiSJ+hLuhgPLdDbimnraSl8irz3iY8sY=
go.opentelemetry.io/otel/exporters/prometheus v0.66.0 h1:vkrK8PAznv2NKt2r+kdu252ccGzkEqLc2aSXbQIALYQ=
go.opentelemetry.io/otel/exporters/prometheus v0.66.0/go.mod h1:V/UB6D3vMF/UBOL5igAsAYnk1nG/bzYYTzvsB16cy7o=
go.opentelemetry.io/otel/exporters/prometheus v0.68.0 h1:QOf2IftqQwITVRJpnn0M7M9ZCbgWfxz4P7i9C9yc2N4=
go.opentelemetry.io/otel/exporters/prometheus v0.68.0/go.mod h1:bgSvqu2TWGXiz7yr5UTMfObH8oqxJWHTnubQ3ef9BO4=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 h1:hqxVTu/GtBF+vJ8d1fzW7fRxZFvgoDjWcxwwCaFDYpU=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0/go.mod h1:z5fVEF4X5v0ESvlJqBrrFlBVoj5EQuefZpzsu7R+x5Q=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0 h1:PR9eAf7o0dQs3hshZNZpE9aW2dXWX/KdDf6pJilVD3U=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.46.0/go.mod h1:2Z4KyNdH1uuzivdinyfGsxzNNT/Rl45pwtVwfYVI0xk=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.44.0 h1:bl2S7Ubua0Nms+D/gAmznQTd4dxxMA93aKbcpKqiTCs=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.44.0/go.mod h1:L0hRV50XdVIODHUfWEqGRCXQvj2rV82STVo12FMFBU0=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0 h1:KdRxPiAoMptR3vfWzvjjvutTsSiwbC2uG0496rzZNfo=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.46.0/go.mod h1:K/qSA+3G7Eovxi4K09wzrAgkWRnosS0DAOZeEpve7sM=
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8=
go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o=
go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA=
go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=
go.opentelemetry.io/otel/metric/x v0.68.0 h1:TA/cBT23D3MnxYPwHL7YFOdYGdx0A0v+s7Mzotpd1dU=
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI=
go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM=
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE=
go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4=
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c=
go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI=
go.opentelemetry.io/proto/otlp v1.10.0 h1:IQRWgT5srOCYfiWnpqUYz9CVmbO8bFmKcwYxpuCSL2g=
go.opentelemetry.io/proto/otlp v1.10.0/go.mod h1:/CV4QoCR/S9yaPj8utp3lvQPoqMtxXdzn7ozvvozVqk=
go.opentelemetry.io/proto/otlp v1.11.0 h1:5rrYs0Ykyj50sdU/JU0x8etU+LubXWb+gED6TbEdMIk=
go.opentelemetry.io/proto/otlp v1.11.0/go.mod h1:SmVizdCOAm3XBtG1g1NnOdhW6jtddT72hLMhv8VwA8E=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ=
go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976 h1:X8Hz2ImujgbmetVuW+w2YkyZChE3cBpZi2P158rTG9M=
golang.org/x/exp v0.0.0-20260611194520-c48552f49976/go.mod h1:vnf4pv9iKZXY58sQE1L86zmNWJ4159e1RkcWiLCkeEY=
golang.org/x/exp v0.0.0-20260824195058-e88cd73687aa h1:QSyA8ishJCyT21kER9KwNt0b7BM3iRK4x9QXhjN5Fdk=
golang.org/x/exp v0.0.0-20260824195058-e88cd73687aa/go.mod h1:zeBbvyFKDaLwa7CH/zI8KXt7gTl14SF7sO08Pl5jBCM=
golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk=
golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys=
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7 h1:jQ9p21COKWjP3VwuFrNRiiOTMh3mPpN45R7SLrH/HUU=
google.golang.org/genproto/googleapis/api v0.0.0-20260630182238-925bb5da69e7/go.mod h1:KqHwBx2upmfa1XSi1WuRvC+2VGCLtooKkfmyvRbUmqA=
google.golang.org/genproto/googleapis/api v0.0.0-20260904194346-d0f1323225a4 h1:NCe/UiklGd/9xjT+ROBVhJ1kf6TRQaFedsR+z7u1gvo=
google.golang.org/genproto/googleapis/api v0.0.0-20260904194346-d0f1323225a4/go.mod h1:fJ2lYaWjqNknJyQBOCd0fA3HnEElJqGplH71a2txi+g=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7 h1:eM/YSd5bBFagF51o1E745Ta7RwzpW0h+z+QDNZOgmQ8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260630182238-925bb5da69e7/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260904194346-d0f1323225a4 h1:5t+ZydAFj5kGVLrgCvLmpmCf9ylGRd64hpEronfRaws=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260904194346-d0f1323225a4/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
google.golang.org/grpc v1.82.0 h1:vguDnZUPjE26w09A63VoxZPnvPjB5Riyc0mkXPFmAIU=
google.golang.org/grpc v1.82.0/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA=
google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU=
google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+19
View File
@@ -34,6 +34,19 @@ type ServiceConfig struct {
// usage are re-fetched over REST.
PollInterval time.Duration `yaml:"pollInterval" json:"pollInterval,omitempty" env:"ECONET_POLL_INTERVAL"`
// EnableWebUI toggles the admin UI served at /. It defaults to enabled:
// a pointer so an unset value (nil) is distinguishable from an explicit
// false, which is what makes the default actually true at runtime —
// LoadEnv's plain env.Parse does not apply the `default` tag (that tag
// only feeds the JSON schema). Use WebUIEnabled to read it.
EnableWebUI *bool `yaml:"enableWebUI" json:"enableWebUI,omitempty" env:"ECONET_ENABLE_WEB_UI" default:"true"`
// DisableWaterUsage skips the per-device water-usage REST call on each
// refresh. Handy for units that don't report water usage, where the call is
// wasted work and just produces debug-log noise. Zero value (false) keeps
// water usage enabled, so unlike EnableWebUI this needs no pointer.
DisableWaterUsage bool `yaml:"disableWaterUsage" json:"disableWaterUsage,omitempty" env:"ECONET_DISABLE_WATER_USAGE" default:"false"`
// Embeds go-app config, used by go-app to
// merge custom config into go-app config, and to produce
// a complete configuration json schema
@@ -51,6 +64,12 @@ func (c *ServiceConfig) LoadEnv() error {
return env.Parse(c)
}
// WebUIEnabled reports whether the admin UI should be served. Unset defaults to
// true; set enableWebUI: false (or ECONET_ENABLE_WEB_UI=false) to disable it.
func (c *ServiceConfig) WebUIEnabled() bool {
return c.EnableWebUI == nil || *c.EnableWebUI
}
// GetPollInterval returns the configured poll interval or the default.
func (c *ServiceConfig) GetPollInterval() time.Duration {
if c.PollInterval <= 0 {
+24
View File
@@ -0,0 +1,24 @@
package config
import "testing"
func TestWebUIEnabledDefaultsTrue(t *testing.T) {
tru, fls := true, false
cases := []struct {
name string
in *bool
want bool
}{
{"unset defaults to enabled", nil, true},
{"explicit true", &tru, true},
{"explicit false", &fls, false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
c := &ServiceConfig{EnableWebUI: tc.in}
if got := c.WebUIEnabled(); got != tc.want {
t.Errorf("WebUIEnabled() = %v, want %v", got, tc.want)
}
})
}
}
+10 -1
View File
@@ -22,6 +22,7 @@ import (
// Hand-written tools (switch back by using this import instead):
// econetmcp "gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/econet/econetmcp"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/econet/econetmetrics"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/econet/econetui"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/service"
)
@@ -32,6 +33,7 @@ type EconetService struct {
client *econetclient.Client
grpc *econetgrpc.EconetGRPCServer
mcp *econetmcp.EconetMCPServer
ui *econetui.EconetUIServer
metrics *econetmetrics.Collector
}
@@ -48,6 +50,9 @@ func (e *EconetService) Init(ctx context.Context, cfg *config.ServiceConfig) (se
e.client = econetclient.New(cfg, e.log)
e.grpc = econetgrpc.NewEconetGRPCServer(ctx, cfg, e.client)
e.mcp = econetmcp.NewEconetMCPServer(ctx, cfg, e.grpc)
if cfg.WebUIEnabled() {
e.ui = econetui.NewEconetUIServer(ctx, cfg, e.grpc)
}
e.metrics = econetmetrics.NewCollector(ctx, cfg, e.client)
if err := e.metrics.RegisterGauges(); err != nil {
return nil, err
@@ -100,9 +105,13 @@ func (e *EconetService) GetGRPC() *optsgrpc.AppGRPC {
}
func (e *EconetService) GetHTTP() *optshttp.AppHTTP {
handlers := e.mcp.GetHandlers()
if e.ui != nil {
handlers = append(handlers, e.ui.GetHandlers()...)
}
return &optshttp.AppHTTP{
Ctx: e.ctx,
Handlers: e.mcp.GetHandlers(),
Handlers: handlers,
HealthChecks: e.healthChecks(),
}
}
+31 -11
View File
@@ -34,11 +34,12 @@ const (
// It is safe for concurrent use: Refresh swaps the device map under a lock,
// and readers take a read lock.
type Client struct {
email string
password string
costPerKWH float64
http *http.Client
log *zerolog.Logger
email string
password string
costPerKWH float64
disableWaterUsage bool
http *http.Client
log *zerolog.Logger
mu sync.RWMutex
token string
@@ -52,12 +53,13 @@ func New(cfg *config.ServiceConfig, log *zerolog.Logger) *Client {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: cfg.EconetTLSInsecure} //nolint:gosec // opt-in via EconetTLSInsecure
return &Client{
email: cfg.EconetEmail,
password: cfg.EconetPassword,
costPerKWH: cfg.CostPerKWH,
http: &http.Client{Transport: transport, Timeout: 15 * time.Second},
log: log,
devices: map[string]*Device{},
email: cfg.EconetEmail,
password: cfg.EconetPassword,
costPerKWH: cfg.CostPerKWH,
disableWaterUsage: cfg.DisableWaterUsage,
http: &http.Client{Transport: transport, Timeout: 15 * time.Second},
log: log,
devices: map[string]*Device{},
}
}
@@ -100,6 +102,7 @@ func (c *Client) Refresh(ctx context.Context) error {
devices := make(map[string]*Device, len(equipment))
for _, raw := range equipment {
d := newDevice(raw, now)
c.traceRawEquipment(d.SerialNumber, raw)
if d.SerialNumber == "" {
continue
}
@@ -160,6 +163,20 @@ func (c *Client) SetMode(ctx context.Context, serial, mode string) error {
return nil
}
// traceRawEquipment logs one device's undecoded equipment block so the full set
// of "@..." datapoints (including fields we don't decode, e.g. any image/model)
// can be inspected. The level guard keeps us from marshaling unless trace is on.
func (c *Client) traceRawEquipment(serial string, raw map[string]json.RawMessage) {
if c.log.GetLevel() > zerolog.TraceLevel {
return
}
b, err := json.Marshal(raw)
if err != nil {
return
}
c.log.Trace().Str("serial", serial).RawJSON("equipment", b).Msg("econet: raw equipment payload")
}
func (c *Client) clearToken() {
c.mu.Lock()
c.token = ""
@@ -234,6 +251,9 @@ func (c *Client) fetchUsage(ctx context.Context, d *Device) {
} else {
c.log.Debug().Err(err).Str("serial", d.SerialNumber).Msg("energy usage poll failed")
}
if c.disableWaterUsage {
return
}
if w, _, err := c.usage(ctx, d, "waterUsage"); err == nil {
d.WaterGallons = w
} else {
+10 -1
View File
@@ -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
+66
View File
@@ -0,0 +1,66 @@
package econetclient
import (
"encoding/json"
"reflect"
"testing"
"time"
)
// sampleGen5 is a trimmed but faithful slice of a real getUserDataForApp
// equipment block for a Rheem Gen5 heat-pump water heater (see the values in
// the field decoders it exercises: @TYPE, @MODE enumText incl. "Electric/Gas",
// @HOTWATER "_v2" icon, @SETPOINT limits, @ENABLED, @NAME).
const sampleGen5 = `{
"@TYPE":"heatpumpWaterHeaterGen5",
"@CONNECTED":true,
"@ENABLED":{"constraints":{"enumText":["Disabled","Enabled "],"lowerLimit":0,"upperLimit":1},"status":"Enabled ","value":1},
"@MODE":{"constraints":{"enumText":["Off ","Energy Saver ","Heat Pump ","High Demand ","Electric/Gas ","Vacation "],"lowerLimit":0,"upperLimit":5},"status":"Energy Saver ","value":1},
"@HOTWATER":"ic_tank_hundread_percent_v2.png",
"@SETPOINT":{"constraints":{"lowerLimit":110,"upperLimit":140},"value":135},
"@NAME":{"constraints":{"stringLength":64},"value":"Heat Pump Water Heater"},
"@RUNNING":"",
"@ALERTCOUNT":0,
"device_name":"3224625639131449",
"device_type":"WH",
"serial_number":"04-17-1a-0d-22-11-25-c0-01"
}`
func TestNewDeviceGen5(t *testing.T) {
var info map[string]json.RawMessage
if err := json.Unmarshal([]byte(sampleGen5), &info); err != nil {
t.Fatalf("bad sample: %v", err)
}
d := newDevice(info, time.Now())
if d.SerialNumber != "04-17-1a-0d-22-11-25-c0-01" {
t.Errorf("serial = %q", d.SerialNumber)
}
if d.GenericType != "heatpumpWaterHeaterGen5" {
t.Errorf("genericType = %q", d.GenericType)
}
if d.FriendlyName != "Heat Pump Water Heater" {
t.Errorf("friendlyName = %q", d.FriendlyName)
}
if !d.Enabled {
t.Errorf("enabled = false, want true")
}
if d.Mode != "energy-saving" {
t.Errorf("mode = %q, want energy-saving", d.Mode)
}
if d.Setpoint != 135 || d.SetpointMin != 110 || d.SetpointMax != 140 {
t.Errorf("setpoint = %d [%d,%d], want 135 [110,140]", d.Setpoint, d.SetpointMin, d.SetpointMax)
}
if d.HotWaterAvailability != 100 {
t.Errorf("hotWater = %d, want 100", d.HotWaterAvailability)
}
if len(d.Raw) == 0 {
t.Errorf("raw payload not retained")
}
// "Electric/Gas" must map to a real, settable mode (not dropped as unknown).
want := []string{"off", "energy-saving", "heat-pump", "high-demand", "electric-gas", "vacation"}
if got := d.SupportedModes(); !reflect.DeepEqual(got, want) {
t.Errorf("supportedModes = %v, want %v", got, want)
}
}
+13
View File
@@ -27,5 +27,18 @@ func deviceToProto(d *econetclient.Device) *pb.Device {
AlertCount: int32(d.AlertCount),
Away: d.Away,
LastUpdated: timestamppb.New(d.LastUpdated),
SupportedModes: supportedModes(d.SupportedModes()),
}
}
// supportedModes maps the device's mode slugs to proto enums, dropping any that
// aren't settable (e.g. "unknown").
func supportedModes(slugs []string) []pb.Mode {
out := make([]pb.Mode, 0, len(slugs))
for _, slug := range slugs {
if m, ok := modeFromSlug(slug); ok {
out = append(out, m)
}
}
return out
}
+26
View File
@@ -71,6 +71,17 @@ func (s *EconetGRPCServer) GetDevice(ctx context.Context, req *pb.GetDeviceReque
return &pb.GetDeviceResponse{Device: deviceToProto(d)}, nil
}
// DeviceRawJSON returns the undecoded EcoNet equipment payload for a device,
// used by the web UI's debug view. ok is false if the serial is unknown or no
// raw payload was captured. It is a debug accessor, not part of the RPC surface.
func (s *EconetGRPCServer) DeviceRawJSON(serial string) ([]byte, bool) {
d := s.client.Device(serial)
if d == nil || len(d.Raw) == 0 {
return nil, false
}
return d.Raw, true
}
// modeSlugs maps the settable proto Mode enum to the normalized slugs the
// client (and Device.mode) use. MODE_UNSPECIFIED is intentionally absent;
// protovalidate rejects it before we get here.
@@ -83,6 +94,21 @@ var modeSlugs = map[pb.Mode]string{
pb.Mode_MODE_GAS: "gas",
pb.Mode_MODE_PERFORMANCE: "performance",
pb.Mode_MODE_VACATION: "vacation",
pb.Mode_MODE_ELECTRIC_GAS: "electric-gas",
}
// ModeSlug returns the normalized slug for a settable Mode, or "" if unknown.
func ModeSlug(m pb.Mode) string { return modeSlugs[m] }
// modeFromSlug is the reverse of modeSlugs; ok is false for slugs with no
// settable enum (e.g. "unknown").
func modeFromSlug(slug string) (pb.Mode, bool) {
for m, s := range modeSlugs {
if s == slug {
return m, true
}
}
return pb.Mode_MODE_UNSPECIFIED, false
}
func (s *EconetGRPCServer) SetMode(ctx context.Context, req *pb.SetModeRequest) (
+162
View File
@@ -0,0 +1,162 @@
package econetui
import (
"bytes"
"context"
"encoding/json"
"net/http"
"strings"
pb "gitea.libretechconsulting.com/rmcguire/econet-exporter/api/econet/v1alpha1"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/econet/econetgrpc"
)
// cardView is the template model for one device card.
type cardView struct {
Device *pb.Device
Icon string // static asset path for the device type
Modes []modeOption // settable modes for the dropdown
Pending string // pretty label of an in-flight mode change, if any
Error string // last mode-change error, if any
}
type modeOption struct {
Value string // proto enum name, e.g. MODE_HEAT_PUMP
Label string // display label, e.g. Heat Pump
Selected bool
}
type pageView struct {
Devices []cardView
}
func (s *EconetUIServer) handleIndex(w http.ResponseWriter, r *http.Request) {
// A full page load is a "fresh get": show reported state, ignore pending.
s.render(w, "layout", pageView{Devices: s.deviceViews(r.Context(), false)})
}
func (s *EconetUIServer) handleDevices(w http.ResponseWriter, r *http.Request) {
// The polling refresh honors pending so an in-flight change stays visible
// until it lands or its TTL lapses.
s.render(w, "devices", pageView{Devices: s.deviceViews(r.Context(), true)})
}
func (s *EconetUIServer) handleSetMode(w http.ResponseWriter, r *http.Request) {
serial := r.PathValue("serial")
modeName := r.FormValue("mode")
modeVal, ok := pb.Mode_value[modeName]
if !ok || pb.Mode(modeVal) == pb.Mode_MODE_UNSPECIFIED {
s.renderCard(w, r.Context(), serial, "invalid mode "+modeName)
return
}
_, err := s.econetGRPC.SetMode(r.Context(), &pb.SetModeRequest{
SerialNumber: serial,
Mode: pb.Mode(modeVal),
})
if err != nil {
s.log.Warn().Err(err).Str("serial", serial).Msg("ui: set mode failed")
s.renderCard(w, r.Context(), serial, err.Error())
return
}
s.pending.set(serial, econetgrpc.ModeSlug(pb.Mode(modeVal)))
s.renderCard(w, r.Context(), serial, "")
}
// handleDebug returns the raw EcoNet payload for a device, pretty-printed, for
// the bug-icon modal.
func (s *EconetUIServer) handleDebug(w http.ResponseWriter, r *http.Request) {
serial := r.PathValue("serial")
raw, ok := s.econetGRPC.DeviceRawJSON(serial)
if !ok {
s.render(w, "debug", "No raw payload captured for "+serial+" yet.")
return
}
var buf bytes.Buffer
if err := json.Indent(&buf, raw, "", " "); err != nil {
buf.Write(raw)
}
s.render(w, "debug", buf.String())
}
// deviceViews builds card views for all devices. When usePending is true, an
// in-flight mode change is shown as a pending badge (and cleared once the
// reported mode catches up).
func (s *EconetUIServer) deviceViews(ctx context.Context, usePending bool) []cardView {
resp, err := s.econetGRPC.ListDevices(ctx, &pb.ListDevicesRequest{})
if err != nil {
s.log.Error().Err(err).Msg("ui: list devices failed")
return nil
}
views := make([]cardView, 0, len(resp.GetDevices()))
for _, d := range resp.GetDevices() {
views = append(views, s.toCardView(d, usePending))
}
return views
}
// renderCard re-renders a single device's card, used for the HTMX swap after a
// mode change. A successful change is optimistic (pending badge shown).
func (s *EconetUIServer) renderCard(w http.ResponseWriter, ctx context.Context, serial, errMsg string) {
resp, err := s.econetGRPC.GetDevice(ctx, &pb.GetDeviceRequest{SerialNumber: serial})
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
cv := s.toCardView(resp.GetDevice(), true)
cv.Error = errMsg
s.render(w, "card", cv)
}
func (s *EconetUIServer) toCardView(d *pb.Device, usePending bool) cardView {
cv := cardView{Device: d, Icon: iconFor(d.GetGenericType())}
for _, m := range d.GetSupportedModes() {
slug := econetgrpc.ModeSlug(m)
cv.Modes = append(cv.Modes, modeOption{
Value: m.String(),
Label: prettyMode(slug),
Selected: slug == d.GetMode(),
})
}
if usePending {
if desired, ok := s.pending.get(d.GetSerialNumber()); ok {
if desired == d.GetMode() {
s.pending.clear(d.GetSerialNumber()) // reported caught up
} else {
cv.Pending = prettyMode(desired)
}
}
}
return cv
}
func (s *EconetUIServer) render(w http.ResponseWriter, name string, data any) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := s.tmpl.ExecuteTemplate(w, name, data); err != nil {
s.log.Error().Err(err).Str("template", name).Msg("ui: render failed")
}
}
// iconFor maps a device's generic type to an embedded SVG asset. It matches
// loosely (case/spacing/underscore-insensitive substrings) because the reported
// @TYPE varies in form across firmware (e.g. "heatpumpWaterHeater", "HeatPump",
// "Hybrid Electric"); unrecognized types fall back to a generic icon.
func iconFor(genericType string) string {
t := strings.NewReplacer(" ", "", "_", "", "-", "").Replace(strings.ToLower(genericType))
switch {
case strings.Contains(t, "heatpump"), strings.Contains(t, "hybrid"):
return "/static/icons/heatpump.svg"
case strings.Contains(t, "tankless"):
return "/static/icons/tankless.svg"
case strings.Contains(t, "gas"):
return "/static/icons/gas.svg"
case strings.Contains(t, "electric"):
return "/static/icons/electric.svg"
default:
return "/static/icons/unknown.svg"
}
}
+54
View File
@@ -0,0 +1,54 @@
package econetui
import (
"sync"
"time"
)
// pendingStore holds best-effort "desired mode" hints for the brief, async
// window between a SetMode publish and the Rheem cloud reporting the new mode.
// Entries expire after a TTL so a mode change that never takes hold quietly
// falls back to the reported state (a "fresh get") rather than showing a stuck
// pending badge forever.
type pendingStore struct {
mu sync.Mutex
ttl time.Duration
m map[string]pendingEntry
}
type pendingEntry struct {
desired string // desired mode slug
expiresAt time.Time
}
func newPendingStore(ttl time.Duration) *pendingStore {
return &pendingStore{ttl: ttl, m: make(map[string]pendingEntry)}
}
func (p *pendingStore) set(serial, desired string) {
p.mu.Lock()
defer p.mu.Unlock()
p.m[serial] = pendingEntry{desired: desired, expiresAt: time.Now().Add(p.ttl)}
}
// get returns the desired mode slug for a serial, or ("", false) if there is no
// pending change or it has expired (expired entries are dropped).
func (p *pendingStore) get(serial string) (string, bool) {
p.mu.Lock()
defer p.mu.Unlock()
e, ok := p.m[serial]
if !ok {
return "", false
}
if time.Now().After(e.expiresAt) {
delete(p.m, serial)
return "", false
}
return e.desired, true
}
func (p *pendingStore) clear(serial string) {
p.mu.Lock()
defer p.mu.Unlock()
delete(p.m, serial)
}
+117
View File
@@ -0,0 +1,117 @@
/*
Package econetui serves a small admin UI at / for viewing EcoNet devices and
changing their operating mode. It renders server-side HTML (html/template with
embedded assets) and uses HTMX for interactivity; device reads and mode writes
go through the in-process gRPC server, exactly like the MCP packages. Auth is
left to the edge (oauth2-proxy) — this package serves the human surface at /
and the mode-write at /ui/, leaving /health, /metrics, and /api untouched.
*/
package econetui
import (
"context"
"embed"
"fmt"
"html/template"
"io/fs"
"net/http"
"strings"
"time"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
"github.com/rs/zerolog"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/config"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/econet/econetgrpc"
)
//go:embed templates/*.html
var templatesFS embed.FS
//go:embed static
var staticFS embed.FS
// pendingTTL bounds how long an optimistic mode change is shown before the UI
// falls back to the reported state.
const pendingTTL = 90 * time.Second
type EconetUIServer struct {
ctx context.Context
cfg *config.ServiceConfig
log *zerolog.Logger
econetGRPC *econetgrpc.EconetGRPCServer
tmpl *template.Template
pending *pendingStore
}
func NewEconetUIServer(ctx context.Context, cfg *config.ServiceConfig,
grpc *econetgrpc.EconetGRPCServer,
) *EconetUIServer {
tmpl := template.Must(template.New("").Funcs(template.FuncMap{
"prettyMode": prettyMode,
"fillClass": fillClass,
"fillWidth": fillWidth,
}).ParseFS(templatesFS, "templates/*.html"))
return &EconetUIServer{
ctx: ctx,
cfg: cfg,
log: zerolog.Ctx(ctx),
econetGRPC: grpc,
tmpl: tmpl,
pending: newPendingStore(pendingTTL),
}
}
func (s *EconetUIServer) GetHandlers() []opts.HTTPHandler {
staticSub, _ := fs.Sub(staticFS, "static")
mux := http.NewServeMux()
mux.HandleFunc("GET /{$}", s.handleIndex)
mux.HandleFunc("GET /ui/devices", s.handleDevices)
mux.HandleFunc("GET /ui/devices/{serial}/debug", s.handleDebug)
mux.HandleFunc("POST /ui/devices/{serial}/mode", s.handleSetMode)
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
s.log.Debug().Msg("Econet admin UI ready at /")
return []opts.HTTPHandler{{Prefix: "/", Handler: mux}}
}
// prettyMode turns a mode slug ("heat-pump") into a display label ("Heat Pump").
func prettyMode(slug string) string {
switch slug {
case "":
return "Unknown"
case "electric-gas":
return "Electric/Gas"
}
words := strings.Split(slug, "-")
for i, w := range words {
if w != "" {
words[i] = strings.ToUpper(w[:1]) + w[1:]
}
}
return strings.Join(words, " ")
}
// fillClass buckets a hot-water fill percentage into a color class. It takes
// int32 to match the proto Device field (html/template is strict about types).
func fillClass(pct int32) string {
switch {
case pct >= 66:
return "fill-high"
case pct >= 33:
return "fill-mid"
default:
return "fill-low"
}
}
// fillWidth returns a safe CSS width for the fill bar.
func fillWidth(pct int32) template.CSS {
if pct < 0 {
pct = 0
}
return template.CSS(fmt.Sprintf("width:%d%%", pct))
}
+151
View File
@@ -0,0 +1,151 @@
/* Layout + components for the EcoNet admin UI. Colors come from Pico's CSS
custom properties so light and dark themes both work without overrides. */
body {
max-width: 1100px;
margin: 0 auto;
padding: 2.5rem 2rem;
}
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
margin-bottom: 2.5rem;
}
.app-header hgroup { margin-bottom: 0; }
.theme-toggle {
flex: 0 0 auto;
width: 3rem;
height: 3rem;
padding: 0;
border-radius: 50%;
font-size: 1.25rem;
line-height: 1;
}
/* Comfortable, capped card width that wraps and centers, so a single device
sits in a tidy card surrounded by whitespace rather than stretching wide or
getting crammed. min(100%, 420px) keeps it fluid on narrow screens. */
.device-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 460px));
justify-content: center;
gap: 2rem;
}
.device-card {
margin: 0;
padding: 2rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.card-head {
display: flex;
align-items: center;
gap: 1rem;
}
.device-icon {
flex: 0 0 auto;
width: 56px;
height: 56px;
color: var(--pico-primary);
}
.card-title { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.card-title strong { display: block; font-size: 1.2rem; }
.card-title small { color: var(--pico-muted-color); word-break: break-all; }
.bug-btn {
flex: 0 0 auto;
padding: 0.25rem 0.4rem;
background: none;
border: none;
border-radius: var(--pico-border-radius);
font-size: 1.1rem;
line-height: 1;
cursor: pointer;
opacity: 0.55;
transition: opacity 0.15s ease;
}
.bug-btn:hover { opacity: 1; }
.dot {
flex: 0 0 auto;
width: 0.8rem;
height: 0.8rem;
border-radius: 50%;
display: inline-block;
}
.dot-ok { background: var(--pico-color-green-500, #22c55e); }
.dot-off { background: var(--pico-color-red-500, #ef4444); }
.stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem 1.5rem;
}
.stats > div { display: flex; flex-direction: column; gap: 0.2rem; }
.stats span { color: var(--pico-muted-color); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stats b { font-size: 1.1rem; }
.fill { display: flex; flex-direction: column; gap: 0.45rem; }
.fill-head { display: flex; justify-content: space-between; align-items: baseline; }
.fill-head span { color: var(--pico-muted-color); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.fill-meter {
height: 0.6rem;
border-radius: 999px;
overflow: hidden;
background: color-mix(in srgb, var(--pico-muted-color) 22%, transparent);
}
.fill-bar { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.fill-high { background: var(--pico-color-green-500, #22c55e); }
.fill-mid { background: var(--pico-color-amber-500, #f59e0b); }
.fill-low { background: var(--pico-color-red-500, #ef4444); }
.card-foot {
display: flex;
flex-direction: column;
gap: 0.6rem;
}
.mode-label { margin: 0; font-size: 0.85rem; color: var(--pico-muted-color); }
.mode-label select { margin-top: 0.35rem; margin-bottom: 0; }
.mode-fixed { color: var(--pico-muted-color); }
.badge {
align-self: flex-start;
padding: 0.2rem 0.55rem;
border-radius: var(--pico-border-radius);
font-size: 0.8rem;
}
.badge-pending {
background: var(--pico-primary-background);
color: var(--pico-primary-inverse);
}
.badge-error {
background: var(--pico-color-red-500, #ef4444);
color: #fff;
}
.empty-state { grid-column: 1 / -1; text-align: center; padding: 3rem 1rem; }
.debug-modal pre {
max-height: 65vh;
overflow: auto;
margin: 0;
}
.debug-modal code { white-space: pre; }
/* Mobile: tighten spacing; the grid already collapses to a single full-width
column via minmax(min(100%, 420px), …). */
@media (max-width: 480px) {
body { padding: 1.25rem 1rem; }
.app-header { margin-bottom: 1.5rem; }
.app-header h1 { font-size: 1.6rem; }
.device-grid { gap: 1.25rem; }
.device-card { padding: 1.5rem; gap: 1.25rem; }
.device-icon { width: 48px; height: 48px; }
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="14" y="8" width="20" height="32" rx="4"/>
<line x1="18" y1="40" x2="18" y2="43"/>
<line x1="30" y1="40" x2="30" y2="43"/>
<path d="M25 15l-5 7h4l-1 7 6-8h-4z" fill="currentColor" stroke="none"/>
</svg>

After

Width:  |  Height:  |  Size: 397 B

+6
View File
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="14" y="6" width="20" height="28" rx="4"/>
<line x1="18" y1="34" x2="18" y2="37"/>
<line x1="30" y1="34" x2="30" y2="37"/>
<path d="M24 38c-3 0-5 2-5 4.5S21 46 24 46s5-1.5 5-3.5c0-3-3-3.5-2-6.5-2 1-3 2.5-3 4.5z"/>
</svg>

After

Width:  |  Height:  |  Size: 415 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="14" y="12" width="20" height="30" rx="4"/>
<line x1="18" y1="42" x2="18" y2="45"/>
<line x1="30" y1="42" x2="30" y2="45"/>
<circle cx="24" cy="9" r="6"/>
<path d="M24 5.5v7M20.5 9h7M21.5 6.5l5 5M26.5 6.5l-5 5"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="12" y="10" width="24" height="22" rx="3"/>
<line x1="18" y1="32" x2="18" y2="40"/>
<line x1="30" y1="32" x2="30" y2="40"/>
<line x1="17" y1="17" x2="31" y2="17"/>
<circle cx="24" cy="25" r="3"/>
</svg>

After

Width:  |  Height:  |  Size: 399 B

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<rect x="14" y="8" width="20" height="32" rx="4"/>
<line x1="18" y1="40" x2="18" y2="43"/>
<line x1="30" y1="40" x2="30" y2="43"/>
<path d="M21 20a3 3 0 1 1 4 2.8c-1 .5-1 1.2-1 2.2"/>
<line x1="24" y1="30" x2="24" y2="30.5"/>
</svg>

After

Width:  |  Height:  |  Size: 421 B

File diff suppressed because one or more lines are too long
+57
View File
@@ -0,0 +1,57 @@
{{define "card"}}
<article id="card-{{.Device.SerialNumber}}" class="device-card">
<div class="card-head">
<img class="device-icon" src="{{.Icon}}" alt="" width="56" height="56">
<div class="card-title">
<strong>{{.Device.FriendlyName}}</strong>
<small>{{.Device.SerialNumber}}</small>
</div>
<button class="bug-btn" title="Show raw device JSON" aria-label="Show raw device JSON"
hx-get="/ui/devices/{{.Device.SerialNumber}}/debug"
hx-target="#debug-modal-body"
hx-swap="innerHTML"
onclick="document.getElementById('debug-modal').showModal()">🐛</button>
<span class="dot {{if .Device.Connected}}dot-ok{{else}}dot-off{{end}}"
title="{{if .Device.Connected}}Connected{{else}}Disconnected{{end}}"></span>
</div>
<div class="stats">
<div><span>Status</span>
<b>{{if .Device.Running}}🔥 {{prettyMode .Device.RunningState}}{{else}}Idle{{end}}</b></div>
<div><span>Setpoint</span><b>{{.Device.Setpoint}}&deg;F</b></div>
<div><span>Alerts</span>
<b>{{if gt .Device.AlertCount 0}}⚠ {{.Device.AlertCount}}{{else}}0{{end}}</b></div>
</div>
{{if ge .Device.HotWaterAvailability 0}}
<div class="fill">
<div class="fill-head"><span>Hot water</span><b>{{.Device.HotWaterAvailability}}%</b></div>
<div class="fill-meter">
<div class="fill-bar {{fillClass .Device.HotWaterAvailability}}" style="{{fillWidth .Device.HotWaterAvailability}}"></div>
</div>
</div>
{{end}}
<div class="card-foot">
{{if .Modes}}
<label class="mode-label">
Mode
<select name="mode"
hx-post="/ui/devices/{{.Device.SerialNumber}}/mode"
hx-target="#card-{{.Device.SerialNumber}}"
hx-swap="outerHTML"
hx-trigger="change"
{{if .Pending}}disabled aria-busy="true"{{end}}>
{{range .Modes}}
<option value="{{.Value}}" {{if .Selected}}selected{{end}}>{{.Label}}</option>
{{end}}
</select>
</label>
{{if .Pending}}<span class="badge badge-pending" aria-busy="true">Updating → {{.Pending}}…</span>{{end}}
{{else}}
<small class="mode-fixed">Mode: {{prettyMode .Device.Mode}} (not settable)</small>
{{end}}
{{if .Error}}<span class="badge badge-error" role="alert">{{.Error}}</span>{{end}}
</div>
</article>
{{end}}
+1
View File
@@ -0,0 +1 @@
{{define "debug"}}{{.}}{{end}}
@@ -0,0 +1,10 @@
{{define "devices"}}
{{if .Devices}}
{{range .Devices}}{{template "card" .}}{{end}}
{{else}}
<article class="empty-state">
<p>No EcoNet devices loaded yet.</p>
<small>Device state populates after the first successful cloud poll.</small>
</article>
{{end}}
{{end}}
+57
View File
@@ -0,0 +1,57 @@
{{define "layout"}}<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>EcoNet Admin</title>
<link rel="stylesheet" href="/static/pico.classless.min.css">
<link rel="stylesheet" href="/static/app.css">
<script src="/static/htmx.min.js" defer></script>
<script>
// Set the theme before first paint to avoid a flash.
(function () {
var saved = localStorage.getItem("theme");
var theme = saved || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
document.documentElement.setAttribute("data-theme", theme);
})();
</script>
</head>
<body>
<header class="app-header">
<hgroup>
<h1>EcoNet Admin</h1>
<p>Rheem water heater status &amp; control</p>
</hgroup>
<button id="theme-toggle" class="secondary theme-toggle" aria-label="Toggle dark mode" onclick="toggleTheme()"></button>
</header>
<main>
<div id="devices" class="device-grid" hx-get="/ui/devices" hx-trigger="every 30s" hx-swap="innerHTML">
{{template "devices" .}}
</div>
</main>
<dialog id="debug-modal" class="debug-modal">
<article>
<header>
<button aria-label="Close" rel="prev" onclick="document.getElementById('debug-modal').close()"></button>
<strong>Raw device JSON</strong>
</header>
<pre><code id="debug-modal-body">Loading…</code></pre>
</article>
</dialog>
<script>
function themeIcon(t) { return t === "dark" ? "☀️" : "🌙"; } // sun / moon
function toggleTheme() {
var cur = document.documentElement.getAttribute("data-theme");
var next = cur === "dark" ? "light" : "dark";
document.documentElement.setAttribute("data-theme", next);
localStorage.setItem("theme", next);
document.getElementById("theme-toggle").textContent = themeIcon(next);
}
document.getElementById("theme-toggle").textContent =
themeIcon(document.documentElement.getAttribute("data-theme"));
</script>
</body>
</html>{{end}}
+148
View File
@@ -0,0 +1,148 @@
package econetui
import (
"context"
"net/http/httptest"
"strings"
"testing"
pb "gitea.libretechconsulting.com/rmcguire/econet-exporter/api/econet/v1alpha1"
"gitea.libretechconsulting.com/rmcguire/econet-exporter/pkg/config"
)
func newTestServer(t *testing.T) *EconetUIServer {
t.Helper()
// grpc is nil: the render/view helpers under test never touch it.
return NewEconetUIServer(context.Background(), &config.ServiceConfig{}, nil)
}
func sampleDevice() *pb.Device {
return &pb.Device{
SerialNumber: "SN123",
FriendlyName: "Garage Water Heater",
GenericType: "heatpumpWaterHeater",
Connected: true,
Mode: "energy-saving",
Running: true,
RunningState: "compressor-running",
Setpoint: 120,
HotWaterAvailability: 66,
AlertCount: 1,
SupportedModes: []pb.Mode{
pb.Mode_MODE_HEAT_PUMP,
pb.Mode_MODE_ENERGY_SAVING,
pb.Mode_MODE_HIGH_DEMAND,
},
}
}
func TestCardRendersWithPending(t *testing.T) {
s := newTestServer(t)
d := sampleDevice()
// Simulate an in-flight change to a mode different from the reported one.
s.pending.set(d.SerialNumber, "heat-pump")
cv := s.toCardView(d, true)
if cv.Pending != "Heat Pump" {
t.Fatalf("pending = %q, want %q", cv.Pending, "Heat Pump")
}
if cv.Icon != "/static/icons/heatpump.svg" {
t.Fatalf("icon = %q", cv.Icon)
}
rec := httptest.NewRecorder()
s.render(rec, "card", cv)
body := rec.Body.String()
for _, want := range []string{
`id="card-SN123"`,
"Garage Water Heater",
`hx-post="/ui/devices/SN123/mode"`,
"badge-pending",
"Updating", // "Updating → Heat Pump…"
"Energy Saving",
"Heat Pump",
"High Demand",
"120&deg;F",
"66%",
"fill-meter", // fill-level graph
"fill-high", // 66% → high bucket (>=66)
} {
if !strings.Contains(body, want) {
t.Errorf("card body missing %q\n---\n%s", want, body)
}
}
}
func TestCardConvergenceClearsPending(t *testing.T) {
s := newTestServer(t)
d := sampleDevice()
d.Mode = "heat-pump" // reported now matches the desired
s.pending.set(d.SerialNumber, "heat-pump")
cv := s.toCardView(d, true)
if cv.Pending != "" {
t.Fatalf("pending should clear once reported catches up, got %q", cv.Pending)
}
if _, ok := s.pending.get(d.SerialNumber); ok {
t.Fatalf("pending entry should have been removed after convergence")
}
}
func TestDevicesEmptyState(t *testing.T) {
s := newTestServer(t)
rec := httptest.NewRecorder()
s.render(rec, "devices", pageView{})
if !strings.Contains(rec.Body.String(), "No EcoNet devices loaded yet") {
t.Errorf("empty state not rendered:\n%s", rec.Body.String())
}
}
func TestIconForLoose(t *testing.T) {
cases := map[string]string{
"heatpumpWaterHeater": "/static/icons/heatpump.svg",
"heatpumpWaterHeaterGen5": "/static/icons/heatpump.svg",
"HeatPump": "/static/icons/heatpump.svg",
"Hybrid Electric": "/static/icons/heatpump.svg",
"heat_pump_water_heater": "/static/icons/heatpump.svg",
"gasWaterHeater": "/static/icons/gas.svg",
"tanklessWaterHeater": "/static/icons/tankless.svg",
"electricWaterHeater": "/static/icons/electric.svg",
"somethingElse": "/static/icons/unknown.svg",
"": "/static/icons/unknown.svg",
}
for in, want := range cases {
if got := iconFor(in); got != want {
t.Errorf("iconFor(%q) = %q, want %q", in, got, want)
}
}
}
func TestDebugTemplateEscapes(t *testing.T) {
s := newTestServer(t)
rec := httptest.NewRecorder()
s.render(rec, "debug", `{"@NAME":"<b>x</b>"}`)
body := rec.Body.String()
if strings.Contains(body, "<b>") {
t.Errorf("debug output not escaped: %s", body)
}
if !strings.Contains(body, "&lt;b&gt;") {
t.Errorf("expected escaped JSON, got: %s", body)
}
}
func TestPrettyMode(t *testing.T) {
cases := map[string]string{
"heat-pump": "Heat Pump",
"energy-saving": "Energy Saving",
"off": "Off",
"": "Unknown",
}
for in, want := range cases {
if got := prettyMode(in); got != want {
t.Errorf("prettyMode(%q) = %q, want %q", in, got, want)
}
}
}
+2
View File
@@ -28,6 +28,7 @@ message Device {
int32 alert_count = 16;
bool away = 17;
google.protobuf.Timestamp last_updated = 18;
repeated Mode supported_modes = 19; // modes this device can be set to (may be empty)
}
// Mode is a settable operating mode for a water heater. The values mirror the
@@ -44,6 +45,7 @@ enum Mode {
MODE_GAS = 6;
MODE_PERFORMANCE = 7;
MODE_VACATION = 8;
MODE_ELECTRIC_GAS = 9; // combined electric/gas backup mode (e.g. hybrid units)
}
message ListDevicesRequest {}