Skip to content

Commit 92b33f7

Browse files
committed
Add condition to ensure binary_sensor_discovery_in_progress always defined
1 parent e461a6c commit 92b33f7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

custom_components/edinplus/edinplus.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,15 @@ async def async_response_handler(self,response):
208208
# Get the HA device ID that triggered the event
209209
device_registry = dr.async_get(self._hass)
210210

211-
LOGGER.debug(f"[{self._hostname}] 207 Creating or getting device in registry with no name and id {uuid}")
211+
LOGGER.debug(f"[{self._hostname}] 211 Creating or getting device in registry with no name and id {uuid}")
212212
device_entry = device_registry.async_get_or_create(
213213
config_entry_id=self._entry_id,
214214
identifiers={(DOMAIN, uuid)},
215215
)
216216
for binary_sensor in self.binary_sensors:
217+
found_binary_sensor_channel = False
217218
if binary_sensor.channel == channel and binary_sensor._address == address:
219+
found_binary_sensor_channel = True
218220
LOGGER.info(f"[{self._hostname}] Found binary sensor corresponding to address {binary_sensor._address}, channel {binary_sensor.channel} in HA. Writing state {newstate_numeric > 0}")
219221
if (binary_sensor._is_on == None):
220222
binary_sensor_discovery_in_progress = True
@@ -224,6 +226,9 @@ async def async_response_handler(self,response):
224226
binary_sensor._is_on = (newstate_numeric > 0)
225227
for callback in binary_sensor._callbacks:
226228
callback()
229+
if (found_binary_sensor_channel == False):
230+
LOGGER.warning(f"[{self._hostname}] Binary sensor without corresponding entity found; address {binary_sensor._address}, channel {binary_sensor.channel}")
231+
binary_sensor_discovery_in_progress = False
227232

228233
if (binary_sensor_discovery_in_progress):
229234
LOGGER.debug(f"[{self._hostname}] NOT Firing event for contact module device {uuid} with trigger type {newstate} as discovery active")

custom_components/edinplus/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "local_push",
99
"issue_tracker": "https://github.com/sftgunner/edinplus-integration/issues",
1010
"requirements": [],
11-
"version": "0.6.8"
11+
"version": "0.6.9"
1212
}

0 commit comments

Comments
 (0)