generated from rmcguire/go-server-with-otel
add ui, new config opts
This commit is contained in:
@@ -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) (
|
||||
|
||||
Reference in New Issue
Block a user