Skip to content

Commit ba0dbf8

Browse files
committed
CirclePlus: implement super_loading of Circle base class
1 parent 5938036 commit ba0dbf8

File tree

1 file changed

+11
-36
lines changed

1 file changed

+11
-36
lines changed

plugwise_usb/nodes/circle_plus.py

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,61 +20,36 @@
2020
_LOGGER = logging.getLogger(__name__)
2121

2222
FEATURES_CIRCLE_PLUS = (
23+
NodeFeature.CIRCLE,
24+
NodeFeature.CIRCLEPLUS,
2325
NodeFeature.RELAY,
2426
NodeFeature.RELAY_INIT,
2527
NodeFeature.RELAY_LOCK,
2628
NodeFeature.ENERGY,
2729
NodeFeature.POWER,
28-
NodeFeature.CIRCLE,
29-
NodeFeature.CIRCLEPLUS,
3030
)
3131

32+
3233
class PlugwiseCirclePlus(PlugwiseCircle):
3334
"""Plugwise Circle+ node."""
3435

3536
async def load(self) -> bool:
3637
"""Load and activate Circle+ node features."""
3738
if self._loaded:
3839
return True
39-
if self._cache_enabled:
40-
_LOGGER.debug("Loading Circle node %s from cache", self._node_info.mac)
41-
if await self._load_from_cache():
42-
self._loaded = True
43-
self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
44-
if await self.initialize():
45-
await self._loaded_callback(NodeEvent.LOADED, self.mac)
46-
return True
47-
48-
_LOGGER.info(
49-
"Loading Circle+ node %s from cache failed",
50-
self._node_info.mac,
51-
)
52-
else:
53-
_LOGGER.debug("Loading Circle+ node %s", self._node_info.mac)
54-
55-
# Check if node is online
56-
if not self._available and not await self.is_online():
57-
_LOGGER.warning(
58-
"Failed to load Circle+ node %s because it is not online",
59-
self._node_info.mac,
60-
)
61-
return False
6240

63-
# Get node info
64-
if await self.node_info_update() is None:
65-
_LOGGER.warning(
66-
"Failed to load Circle+ node %s because it is not responding to information request",
67-
self._node_info.mac,
68-
)
41+
_LOGGER.debug("Loading Circle + node %s", self._node_info.mac)
42+
if not await super().load():
43+
_LOGGER.debug("Loading of Circle base node failed")
6944
return False
7045

71-
self._loaded = True
7246
self._setup_protocol(CIRCLE_PLUS_FIRMWARE_SUPPORT, FEATURES_CIRCLE_PLUS)
73-
if not await self.initialize():
74-
return False
47+
if await self.initialize():
48+
await self._loaded_callback(NodeEvent.LOADED, self.mac)
49+
return True
7550

76-
await self._loaded_callback(NodeEvent.LOADED, self.mac)
77-
return True
51+
_LOGGER.debug("Loading of Circle + node %s failed", self._node_info.mac)
52+
return False
7853

7954
async def clock_synchronize(self) -> bool:
8055
"""Synchronize realtime clock. Returns true if successful."""

0 commit comments

Comments
 (0)