From d313d82eb7d18ba55cfa8815a70b6d70c1413fc6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 10 Jan 2023 16:41:16 +0100 Subject: [PATCH] Fix unknown data in influxdb (#85619) --- homeassistant/components/influxdb/sensor.py | 5 ++--- tests/components/influxdb/test_sensor.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/influxdb/sensor.py b/homeassistant/components/influxdb/sensor.py index 24625a66099..67aaae225a8 100644 --- a/homeassistant/components/influxdb/sensor.py +++ b/homeassistant/components/influxdb/sensor.py @@ -18,7 +18,6 @@ from homeassistant.const import ( CONF_UNIT_OF_MEASUREMENT, CONF_VALUE_TEMPLATE, EVENT_HOMEASSISTANT_STOP, - STATE_UNKNOWN, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import PlatformNotReady, TemplateError @@ -248,10 +247,10 @@ class InfluxSensor(SensorEntity): """Get the latest data from Influxdb and updates the states.""" self.data.update() if (value := self.data.value) is None: - value = STATE_UNKNOWN + value = None if self._value_template is not None: value = self._value_template.render_with_possible_json_value( - str(value), STATE_UNKNOWN + str(value), None ) self._state = value diff --git a/tests/components/influxdb/test_sensor.py b/tests/components/influxdb/test_sensor.py index 6bc2014d24e..d595006f413 100644 --- a/tests/components/influxdb/test_sensor.py +++ b/tests/components/influxdb/test_sensor.py @@ -245,7 +245,7 @@ async def test_minimal_config(hass, mock_client, config_ext, queries, set_query_ "unit_of_measurement": "unit", "measurement": "measurement", "where": "where", - "value_template": "value", + "value_template": "123", "database": "db2", "group_function": "fn", "field": "field",