From 1ebdc66cca3450f4d38c5695c7854d252899bd04 Mon Sep 17 00:00:00 2001 From: cyr-ius Date: Mon, 10 Jun 2024 13:04:06 +0200 Subject: [PATCH] Fix state if value function exists --- custom_components/audiconnect/binary_sensor.py | 2 +- custom_components/audiconnect/sensor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/audiconnect/binary_sensor.py b/custom_components/audiconnect/binary_sensor.py index c67295a3..d48dc970 100644 --- a/custom_components/audiconnect/binary_sensor.py +++ b/custom_components/audiconnect/binary_sensor.py @@ -290,6 +290,6 @@ class AudiBinarySensor(AudiEntity, BinarySensorEntity): def is_on(self): """Return is on.""" value = self.getattr(self.entity_description.value) - if value and self.entity_description.value_fn: + if value is not None and self.entity_description.value_fn: return self.entity_description.value_fn(value) return value diff --git a/custom_components/audiconnect/sensor.py b/custom_components/audiconnect/sensor.py index e1e6aa84..db369e3d 100644 --- a/custom_components/audiconnect/sensor.py +++ b/custom_components/audiconnect/sensor.py @@ -288,6 +288,6 @@ class AudiSensor(AudiEntity, SensorEntity): def state(self): """Return sensor state.""" value = self.getattr(self.entity_description.value) - if value and self.entity_description.value_fn: + if value is not None and self.entity_description.value_fn: return self.entity_description.value_fn(value) return value