Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 16 additions & 28 deletions plugwise_usb/nodes/circle_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,26 @@ async def load(self) -> bool:
if self._loaded:
return True
if self._cache_enabled:
_LOGGER.debug("Loading Circle node %s from cache", self._node_info.mac)
_LOGGER.debug("Loading Circle+ node %s from cache", self._mac_in_str)
if await self._load_from_cache():
self._loaded = True
self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
if await self.initialize():
await self._loaded_callback(NodeEvent.LOADED, self.mac)
return True

_LOGGER.info(
"Loading Circle+ node %s from cache failed",
self._node_info.mac,
)
else:
_LOGGER.debug("Loading Circle+ node %s", self._node_info.mac)

# Check if node is online
if not self._available and not await self.is_online():
_LOGGER.warning(
"Failed to load Circle+ node %s because it is not online",
self._node_info.mac,
)
return False

# Get node info
if await self.node_info_update() is None:
_LOGGER.warning(
"Failed to load Circle+ node %s because it is not responding to information request",
self._node_info.mac,
)
return False
if not self._loaded:
_LOGGER.debug("Retrieving info for Circle+ node %s", self._mac_in_str)

# Check if node is online
if (
not self._available
and not await self.is_online()
or await self.node_info_update() is None
):
_LOGGER.warning(
"Failed to load Circle+ node %s because it is not online or not responding",
self._mac_in_str,
)
return False

self._loaded = True

self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
if not await self.initialize():
return False
Expand Down