Skip to content

Commit f7dd745

Browse files
committed
C+ align load-function to circle load-function
1 parent 6be2724 commit f7dd745

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

plugwise_usb/nodes/circle_plus.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,26 @@ async def load(self) -> bool:
3838
if self._loaded:
3939
return True
4040
if self._cache_enabled:
41-
_LOGGER.debug("Loading Circle node %s from cache", self._node_info.mac)
41+
_LOGGER.debug("Loading Circle+ node %s from cache", self._node_info.mac)
4242
if await self._load_from_cache():
4343
self._loaded = True
44-
self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
45-
if await self.initialize():
46-
await self._loaded_callback(NodeEvent.LOADED, self.mac)
47-
return True
48-
49-
_LOGGER.info(
50-
"Loading Circle+ node %s from cache failed",
51-
self._node_info.mac,
52-
)
53-
else:
54-
_LOGGER.debug("Loading Circle+ node %s", self._node_info.mac)
44+
if not self._loaded:
45+
_LOGGER.debug("Retrieving Info For Circle+ node %s", self._mac_in_str)
5546

5647
# Check if node is online
57-
if not self._available and not await self.is_online():
58-
_LOGGER.warning(
59-
"Failed to load Circle+ node %s because it is not online",
60-
self._node_info.mac,
61-
)
62-
return False
63-
64-
# Get node info
65-
if await self.node_info_update() is None:
48+
if (
49+
not self._available
50+
and not await self.is_online()
51+
or await self.node_info_update() is None
52+
):
6653
_LOGGER.warning(
67-
"Failed to load Circle+ node %s because it is not responding to information request",
68-
self._node_info.mac,
54+
"Failed to load Circle+ node %s because it is not online or not responding",
55+
self._mac_in_str,
6956
)
7057
return False
7158

7259
self._loaded = True
60+
7361
self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
7462
if not await self.initialize():
7563
return False

0 commit comments

Comments
 (0)