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:
parent
f3595f790a
commit
df68de8032
1 changed files with 8 additions and 6 deletions
|
@ -172,9 +172,11 @@ class InfluxSensorData(object):
|
||||||
|
|
||||||
points = list(self.influx.query(self.query).get_points())
|
points = list(self.influx.query(self.query).get_points())
|
||||||
if len(points) == 0:
|
if len(points) == 0:
|
||||||
_LOGGER.error('Query returned no points : %s', self.query)
|
_LOGGER.warning('Query returned no points, sensor state set'
|
||||||
return
|
' to UNKNOWN : %s', self.query)
|
||||||
if len(points) > 1:
|
self.value = None
|
||||||
_LOGGER.warning('Query returned multiple points, only first one'
|
else:
|
||||||
' shown : %s', self.query)
|
if len(points) > 1:
|
||||||
self.value = points[0].get('value')
|
_LOGGER.warning('Query returned multiple points, only first'
|
||||||
|
' one shown : %s', self.query)
|
||||||
|
self.value = points[0].get('value')
|
||||||
|
|
Loading…
Add table
Reference in a new issue