Skip to content

Commit b9f652c

Browse files
committed
Improve error messages
1 parent 8828da8 commit b9f652c

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

plugwise_usb/connection/__init__.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def mac_stick(self) -> str:
5050
"""MAC address of USB-Stick. Raises StickError when not connected."""
5151
if not self._manager.is_connected or self._mac_stick is None:
5252
raise StickError(
53-
"No mac address available. " +
54-
"Connect and initialize USB-Stick first."
53+
"No mac address available. Connect and initialize USB-Stick first."
5554
)
5655
return self._mac_stick
5756

@@ -72,8 +71,7 @@ def network_id(self) -> int:
7271
"""Returns the Zigbee network ID. Raises StickError when not connected."""
7372
if not self._manager.is_connected or self._network_id is None:
7473
raise StickError(
75-
"No network ID available. " +
76-
"Connect and initialize USB-Stick first."
74+
"No network ID available. Connect and initialize USB-Stick first."
7775
)
7876
return self._network_id
7977

@@ -82,8 +80,7 @@ def network_online(self) -> bool:
8280
"""Return the network state."""
8381
if not self._manager.is_connected:
8482
raise StickError(
85-
"Network status not available. " +
86-
"Connect and initialize USB-Stick first."
83+
"Network status not available. Connect and initialize USB-Stick first."
8784
)
8885
return self._network_online
8986

@@ -156,15 +153,15 @@ async def initialize_stick(self) -> None:
156153
init_response: StickInitResponse | None = await request.send()
157154
except StickError as err:
158155
raise StickError(
159-
"No response from USB-Stick to initialization request." +
160-
" Validate USB-stick is connected to port " +
161-
f"' {self._manager.serial_path}'"
156+
"No response from USB-Stick to initialization request."
157+
+ " Validate USB-stick is connected to port "
158+
+ f"' {self._manager.serial_path}'"
162159
) from err
163160
if init_response is None:
164161
raise StickError(
165-
"No response from USB-Stick to initialization request." +
166-
" Validate USB-stick is connected to port " +
167-
f"' {self._manager.serial_path}'"
162+
"No response from USB-Stick to initialization request."
163+
+ " Validate USB-stick is connected to port "
164+
+ f"' {self._manager.serial_path}'"
168165
)
169166
self._mac_stick = init_response.mac_decoded
170167
self._network_online = init_response.network_online
@@ -175,9 +172,7 @@ async def initialize_stick(self) -> None:
175172
self._is_initialized = True
176173

177174
if not self._network_online:
178-
raise StickError(
179-
"Zigbee network connection to Circle+ is down."
180-
)
175+
raise StickError("Zigbee network connection to Circle+ is down.")
181176

182177
async def send(
183178
self, request: PlugwiseRequest, suppress_node_errors: bool = True

0 commit comments

Comments
 (0)