From a299ca4db91dc3a8f6da52447f4a21f2b014c026 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Tue, 1 Mar 2022 18:46:28 +0200 Subject: [PATCH] Fix binary sensor exception (#27) --- custom_components/rpi_gpio/binary_sensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/rpi_gpio/binary_sensor.py b/custom_components/rpi_gpio/binary_sensor.py index ab33e49..c20c51b 100644 --- a/custom_components/rpi_gpio/binary_sensor.py +++ b/custom_components/rpi_gpio/binary_sensor.py @@ -82,7 +82,8 @@ class RPiGPIOBinarySensor(BinarySensorEntity): def edge_detected(port): """Edge detection handler.""" - self.hass.add_job(self.async_read_gpio) + if self.hass is not None: + self.hass.add_job(self.async_read_gpio) edge_detect(self._port, edge_detected, self._bouncetime)