Private GIT

Skip to content
Snippets Groups Projects
Commit cea677bb authored by Richard Mitchell's avatar Richard Mitchell
Browse files

Default to something sensible for last udpated time

parent 93c12938
Branches
Tags
No related merge requests found
...@@ -142,7 +142,9 @@ func (c sensorCollector) recordSensor(sensor hue.Sensor, sensorName string, devi ...@@ -142,7 +142,9 @@ func (c sensorCollector) recordSensor(sensor hue.Sensor, sensorName string, devi
c.sensorValue.With(sensorLabels).Set(sensorValue) c.sensorValue.With(sensorLabels).Set(sensorValue)
c.sensorBattery.With(sensorLabels).Set(float64(sensor.Config.Battery)) c.sensorBattery.With(sensorLabels).Set(float64(sensor.Config.Battery))
c.sensorLastUpdated.With(sensorLabels).Set(float64(sensor.State.LastUpdated.Unix())) // let's set a sensible minimum for last updated here: if your sensor last updated before 1970,
// something's clearly not right. No need to set it to 1969 /BCE/.
c.sensorLastUpdated.With(sensorLabels).Set(float64(max(sensor.State.LastUpdated.Unix(), 0)))
if sensor.Config.On { if sensor.Config.On {
c.sensorOn.With(sensorLabels).Set(1) c.sensorOn.With(sensorLabels).Set(1)
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment