Skip to content

Commit

Permalink
Continue loading when Kasa relay fails. #977
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Jan 6, 2025
1 parent 1a2654a commit 4af2854
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hardware/relay/kasa_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class terrariumRelayTPLinkKasa(terrariumRelay):
URL = "^\d{1,3}\.\d{1,3}\.\d{1,3}(,\d{1,3})?$"

def _load_hardware(self):
self._device["device"] = None
# Input format should be either:
# - [IP],[POWER_SWITCH_NR]

Expand All @@ -24,12 +25,15 @@ def _load_hardware(self):
self.__asyncio = terrariumAsync()

address = self._address
if len(address) == 1:
self._device["device"] = SmartPlug(address[0])
self._device["switch"] = 0
else:
self._device["device"] = SmartStrip(address[0])
self._device["switch"] = int(address[1]) - 1
try:
if len(address) == 1:
self._device["device"] = SmartPlug(address[0])
self._device["switch"] = 0
else:
self._device["device"] = SmartStrip(address[0])
self._device["switch"] = int(address[1]) - 1
except Exception as ex:
logger.error(f"Error loading {self} at address {address[0]}: {ex}")

return self._device["device"]

Expand Down

0 comments on commit 4af2854

Please sign in to comment.