Skip to content

Commit

Permalink
Merge pull request #67 from WillCodeForCats/66-unknown-device-reporte…
Browse files Browse the repository at this point in the history
…d-driver-will-not-start

Ignore the address of unknown device types
  • Loading branch information
WillCodeForCats authored Mar 1, 2024
2 parents f551723 + d915ee8 commit cfeb9fa
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions custom_components/tekmar_482/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def __init__(
self._tha_inventory = {}
self.tha_gateway = []
self.tha_devices = []
self.tha_ignore_addr = []
self.online = False

self._tha_fw_ver = None
Expand Down Expand Up @@ -235,13 +236,12 @@ async def async_init_tha(self) -> None:
except KeyError:
_LOGGER.warning(
(
f"Unknown device type {b['type']}. "
"Try power cycling your Gateway 482."
f"Unknown device type {b['type']} at address "
f"{b['address']}. This address will be ignored."
)
)
raise ConfigEntryNotReady(
f"Unknown device type {b['type']}."
)

self.tha_ignore_addr.append(b["address"])

elif tha_method in ["DeviceAttributes"]:
_LOGGER.debug(
Expand Down Expand Up @@ -274,6 +274,10 @@ async def async_init_tha(self) -> None:
]

for address in self._tha_inventory:
if address in self.tha_ignore_addr:
_LOGGER.debug(f"Ignored address {address} while creating devices.")
continue

if (
DEVICE_TYPES[self._tha_inventory[address]["type"]]
== ThaType.THERMOSTAT
Expand Down Expand Up @@ -347,6 +351,10 @@ async def run(self) -> None:
b = p.body
tha_method = name_from_methodID[h["methodID"]]

if b["address"] in self.tha_ignore_addr:
_LOGGER.debug(f"Ignored {p} from address {b['address']}")
continue

if tha_method in ["ReportingState"]:
for gateway in self.tha_gateway:
await gateway.set_reporting_state(b["state"])
Expand Down

0 comments on commit cfeb9fa

Please sign in to comment.