diff --git a/sensors.go b/sensors.go index 766cf4b75f3db20b4a8efe6e54147c1743f8d68d..db80efb6b84652a55d22409f8958d5bf1a7ac63f 100644 --- a/sensors.go +++ b/sensors.go @@ -142,7 +142,9 @@ func (c sensorCollector) recordSensor(sensor hue.Sensor, sensorName string, devi c.sensorValue.With(sensorLabels).Set(sensorValue) 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 { c.sensorOn.With(sensorLabels).Set(1) } else {