mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix unknown data in influxdb (#85619)
This commit is contained in:
parent
65750fec9b
commit
d313d82eb7
@ -18,7 +18,6 @@ from homeassistant.const import (
|
|||||||
CONF_UNIT_OF_MEASUREMENT,
|
CONF_UNIT_OF_MEASUREMENT,
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
STATE_UNKNOWN,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady, TemplateError
|
from homeassistant.exceptions import PlatformNotReady, TemplateError
|
||||||
@ -248,10 +247,10 @@ class InfluxSensor(SensorEntity):
|
|||||||
"""Get the latest data from Influxdb and updates the states."""
|
"""Get the latest data from Influxdb and updates the states."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
if (value := self.data.value) is None:
|
if (value := self.data.value) is None:
|
||||||
value = STATE_UNKNOWN
|
value = None
|
||||||
if self._value_template is not None:
|
if self._value_template is not None:
|
||||||
value = self._value_template.render_with_possible_json_value(
|
value = self._value_template.render_with_possible_json_value(
|
||||||
str(value), STATE_UNKNOWN
|
str(value), None
|
||||||
)
|
)
|
||||||
|
|
||||||
self._state = value
|
self._state = value
|
||||||
|
@ -245,7 +245,7 @@ async def test_minimal_config(hass, mock_client, config_ext, queries, set_query_
|
|||||||
"unit_of_measurement": "unit",
|
"unit_of_measurement": "unit",
|
||||||
"measurement": "measurement",
|
"measurement": "measurement",
|
||||||
"where": "where",
|
"where": "where",
|
||||||
"value_template": "value",
|
"value_template": "123",
|
||||||
"database": "db2",
|
"database": "db2",
|
||||||
"group_function": "fn",
|
"group_function": "fn",
|
||||||
"field": "field",
|
"field": "field",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user