Skip to content

Commit 2fe137a

Browse files
committed
Various black-, docstring-fixes
1 parent 5e5f5d9 commit 2fe137a

File tree

4 files changed

+17
-79
lines changed

4 files changed

+17
-79
lines changed

plugwise/constants.py

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" Plugwise Stick and Smile constants."""
2+
13
### Stick constants ###
24

35
UTF8_DECODE = "utf-8"
@@ -327,40 +329,14 @@
327329
}
328330

329331
SMILES = {
330-
"smile_open_therm_v3": {
331-
"type": "thermostat",
332-
"friendly_name": "Adam",
333-
},
334-
"smile_open_therm_v2": {
335-
"type": "thermostat",
336-
"friendly_name": "Adam",
337-
},
338-
"smile_thermo_v4": {
339-
"type": "thermostat",
340-
"friendly_name": "Anna",
341-
},
342-
"smile_thermo_v3": {
343-
"type": "thermostat",
344-
"friendly_name": "Anna",
345-
},
346-
"smile_thermo_v1": {
347-
"type": "thermostat",
348-
"friendly_name": "Anna",
349-
"legacy": True,
350-
},
351-
"smile_v4": {
352-
"type": "power",
353-
"friendly_name": "P1",
354-
},
355-
"smile_v3": {
356-
"type": "power",
357-
"friendly_name": "P1",
358-
},
359-
"smile_v2": {
360-
"type": "power",
361-
"friendly_name": "P1",
362-
"legacy": True,
363-
},
332+
"smile_open_therm_v3": {"type": "thermostat", "friendly_name": "Adam",},
333+
"smile_open_therm_v2": {"type": "thermostat", "friendly_name": "Adam",},
334+
"smile_thermo_v4": {"type": "thermostat", "friendly_name": "Anna",},
335+
"smile_thermo_v3": {"type": "thermostat", "friendly_name": "Anna",},
336+
"smile_thermo_v1": {"type": "thermostat", "friendly_name": "Anna", "legacy": True,},
337+
"smile_v4": {"type": "power", "friendly_name": "P1",},
338+
"smile_v3": {"type": "power", "friendly_name": "P1",},
339+
"smile_v2": {"type": "power", "friendly_name": "P1", "legacy": True,},
364340
"stretch_v3": {"type": "stretch", "friendly_name": "Stretch", "legacy": True},
365341
"stretch_v2": {"type": "stretch", "friendly_name": "Stretch", "legacy": True},
366342
}

plugwise/exceptions.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,71 @@
1-
# Copyright (C) 2011 Sven Petai <[email protected]>
2-
# Use of this source code is governed by the MIT license found in the LICENSE file.
1+
""" Copyright (C) 2011 Sven Petai <[email protected]>, use of this source code is governed by the MIT license found in the LICENSE file."""
32

43

54
class PlugwiseException(Exception):
65
"""Base error class for this Plugwise library"""
76

8-
pass
97

108
### Stick exceptions ###
119

1210

1311
class PortError(PlugwiseException):
1412
"""Connection to USBstick failed"""
1513

16-
pass
17-
1814

1915
class StickInitError(PlugwiseException):
2016
"""Initialization of USBstick failed"""
2117

22-
pass
23-
2418

2519
class NetworkDown(PlugwiseException):
2620
"""Zigbee network not online"""
2721

28-
pass
29-
3022

3123
class CirclePlusError(PlugwiseException):
3224
"""Connection to Circle+ node failed"""
3325

34-
pass
35-
3626

3727
class ProtocolError(PlugwiseException):
3828
"""Error while decode received data"""
3929

40-
pass
41-
4230

4331
class TimeoutException(PlugwiseException):
4432
"""Timeout expired while waiting for response from node"""
4533

46-
pass
47-
4834

4935
### Smile exceptions ###
5036

5137

5238
class ConnectionFailedError(PlugwiseException):
5339
"""Raised when unable to connect."""
5440

55-
pass
56-
5741

5842
class InvalidAuthentication(PlugwiseException):
5943
"""Raised when unable to authenticate."""
6044

61-
pass
62-
6345

6446
class UnsupportedDeviceError(PlugwiseException):
6547
"""Raised when device is not supported."""
6648

67-
pass
68-
6949

7050
class DeviceSetupError(PlugwiseException):
7151
"""Raised when device is missing critical setup data."""
7252

73-
pass
74-
7553

7654
class DeviceTimeoutError(PlugwiseException):
7755
"""Raised when device is not supported."""
7856

79-
pass
80-
8157

8258
class ErrorSendingCommandError(PlugwiseException):
8359
"""Raised when device is not accepting the command."""
8460

85-
pass
86-
8761

8862
class ResponseError(PlugwiseException):
8963
"""Raised when empty or error in response returned."""
9064

91-
pass
92-
9365

9466
class InvalidXMLError(PlugwiseException):
9567
"""Raised when response holds incomplete or invalid XML data."""
9668

97-
pass
98-
9969

10070
class XMLDataMissingError(PlugwiseException):
10171
"""Raised when xml data is empty."""
102-
103-
pass

plugwise/smile.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ async def _create_session() -> aiohttp.ClientSession:
105105

106106
async def connect(self):
107107
"""Connect to Plugwise device."""
108-
# pylint: disable=too-many-return-statements,raise-missing-from
109108
names = []
110109

111110
result = await self.request(DOMAIN_OBJECTS)
@@ -211,16 +210,9 @@ async def close_connection(self):
211210
await self.websession.close()
212211

213212
async def request(
214-
self,
215-
command,
216-
retry=3,
217-
method="get",
218-
data=None,
219-
headers=None,
213+
self, command, retry=3, method="get", data=None, headers=None,
220214
):
221215
"""Request data."""
222-
# pylint: disable=too-many-return-statements,raise-missing-from
223-
224216
resp = None
225217
url = f"{self._endpoint}{command}"
226218

plugwise/util.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ def int_to_uint(val, octals):
6565
val = val + (1 << bits)
6666
return val
6767

68+
6869
def escape_illegal_xml_characters(xmldata):
6970
"""Replace illegal &-characters."""
7071
return re.sub(r"&([^a-zA-Z#])", r"&amp;\1", xmldata)
7172

73+
7274
def format_measure(measure):
7375
"""Format measure to correct type."""
7476
try:
@@ -88,6 +90,7 @@ def format_measure(measure):
8890
measure = False
8991
return measure
9092

93+
9194
def determine_selected(available, selected, schemas):
9295
"""Determine selected schema from available schemas."""
9396
for schema_a, schema_b in schemas.items():
@@ -96,6 +99,7 @@ def determine_selected(available, selected, schemas):
9699
selected = schema_a
97100
return available, selected
98101

102+
99103
def in_between(now, start, end):
100104
"""Determine timing for schedules."""
101105
if start <= end:
@@ -267,9 +271,7 @@ def __init__(self, hour=0, minute=0, second=0):
267271
def deserialize(self, val):
268272
CompositeType.deserialize(self, val)
269273
self.value = datetime.time(
270-
int(self.hour.value),
271-
int(self.minute.value),
272-
int(self.second.value),
274+
int(self.hour.value), int(self.minute.value), int(self.second.value),
273275
)
274276

275277

0 commit comments

Comments
 (0)