@@ -30,6 +30,7 @@ type EnvironmentalCollector struct {
3030 pm25 * prometheus.Desc
3131 airQuality * prometheus.Desc
3232 waterLevel * prometheus.Desc
33+ lightLevel * prometheus.Desc
3334
3435 m * server.Manager
3536 lat float64
@@ -113,6 +114,11 @@ func NewEnvironmentalCollector(m *server.Manager, lat, long float64) (prometheus
113114 "Water Level" ,
114115 []string {"source" }, nil ,
115116 ),
117+ lightLevel : prometheus .NewDesc (
118+ prometheus .BuildFQName (namespace , "" , "lumen_per_square_meter" ),
119+ "Light Level (Lux)" ,
120+ []string {"source" }, nil ,
121+ ),
116122 }, nil
117123}
118124
@@ -132,6 +138,7 @@ func (c *EnvironmentalCollector) Describe(ch chan<- *prometheus.Desc) {
132138 ch <- c .pm25
133139 ch <- c .airQuality
134140 ch <- c .waterLevel
141+ ch <- c .lightLevel
135142}
136143
137144// Collect sends metric updates into the channel
@@ -273,6 +280,19 @@ func (c *EnvironmentalCollector) Collect(ch chan<- prometheus.Metric) {
273280 ch <- prometheus .MustNewConstMetric (c .waterLevel ,
274281 prometheus .GaugeValue , vf , s .Info ().Topic )
275282 }
283+ if ft := s .Feature ("currentAmbientLightLevel" ); ft .Exists () {
284+ v := ft .Value ()
285+ if v == "" {
286+ continue
287+ }
288+ vf , err := toFloat (v )
289+ if err != nil {
290+ log .Print (err .Error ())
291+ continue
292+ }
293+ ch <- prometheus .MustNewConstMetric (c .lightLevel ,
294+ prometheus .GaugeValue , vf , s .Info ().Topic )
295+ }
276296 }
277297
278298 for dev , temp := range temperature {
0 commit comments