getFriendlyName() string
}
+type ITopicRelay interface {
+ getTopic() string
+}
+
type IRelayData interface {
getRelayData(red, green, blue float64) (map[string]interface{}, string)
}
return relay.Topic
}
+func (relay *ESPRelay) getTopic() string {
+ return relay.Topic
+}
+
// RGBPico defs
type PicoRelayData struct {
parent *RGBPico
time.Sleep(time.Duration(1) * time.Second)
for _, relay := range manager.relays {
// did we get a friendly name capable relay?
- curZig, ok := relay.(IRGBFriendly)
+ curZig, zigOk := relay.(IRGBFriendly)
// this should give us a fairly unique value, location is friendlyname where enabled, otherwise location is location
- if ok {
+ if zigOk {
lightGauge.With(prometheus.Labels{"location": curZig.getFriendlyName()}).Set(curZig.getMetricValue())
} else {
- lightGauge.With(prometheus.Labels{"location": relay.getLocation()}).Set(relay.getMetricValue())
+ curTopic, topicOk := relay.(ITopicRelay)
+ if topicOk {
+ lightGauge.With(prometheus.Labels{"location": curTopic.getTopic()}).Set(relay.getMetricValue())
+ } else {
+
+ lightGauge.With(prometheus.Labels{"location": relay.getLocation()}).Set(relay.getMetricValue())
+ }
}
}
}