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