Influxdb sensor state set to unknown if query return no points (#4148)

* Influxdb sensor state set to unknown if query return no points

* Update influxdb.py
This commit is contained in:
bestlibre 2016-11-03 03:50:18 +01:00 committed by Paulus Schoutsen
parent f3595f790a
commit df68de8032

View file

@ -172,9 +172,11 @@ class InfluxSensorData(object):
points = list(self.influx.query(self.query).get_points())
if len(points) == 0:
_LOGGER.error('Query returned no points : %s', self.query)
return
if len(points) > 1:
_LOGGER.warning('Query returned multiple points, only first one'
' shown : %s', self.query)
self.value = points[0].get('value')
_LOGGER.warning('Query returned no points, sensor state set'
' to UNKNOWN : %s', self.query)
self.value = None
else:
if len(points) > 1:
_LOGGER.warning('Query returned multiple points, only first'
' one shown : %s', self.query)
self.value = points[0].get('value')