From b7f63118973e89bb154294b54759a81dc67f3d21 Mon Sep 17 00:00:00 2001 From: Alessandro Del Prete Date: Tue, 27 Feb 2024 23:41:30 +0100 Subject: [PATCH] Fixed native_value --- custom_components/sinapsi_alfa/api.py | 2 +- custom_components/sinapsi_alfa/sensor.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/sinapsi_alfa/api.py b/custom_components/sinapsi_alfa/api.py index 1825a29..4cff377 100644 --- a/custom_components/sinapsi_alfa/api.py +++ b/custom_components/sinapsi_alfa/api.py @@ -228,7 +228,7 @@ def read_modbus_alfa(self): reg_addr = sensor["modbus_addr"] reg_count = 1 if reg_type == "uint16" else 2 _LOGGER.debug( - f"(read_modbus_alfa) Key: {reg_key} Addr: {reg_addr} Type: {reg_type} DevClass: {reg_dev_class}" + f"(read_modbus_alfa) Key: {reg_key} Addr: {str(reg_addr)} Type: {reg_type} DevClass: {reg_dev_class}" ) if reg_type == "calculated": self.data["potenza_consumata"] = ( diff --git a/custom_components/sinapsi_alfa/sensor.py b/custom_components/sinapsi_alfa/sensor.py index a03b642..1649501 100644 --- a/custom_components/sinapsi_alfa/sensor.py +++ b/custom_components/sinapsi_alfa/sensor.py @@ -125,6 +125,8 @@ def native_value(self): """Return the state of the sensor.""" if self._key in self.coordinator.api.data: return self.coordinator.api.data[self._key] + else: + return None @property def state_attributes(self) -> dict[str, Any] | None: