|
5 | 5 | from collections.abc import Callable |
6 | 6 | from copy import copy |
7 | 7 | from datetime import UTC, datetime |
8 | | -from enum import Enum |
9 | 8 | import logging |
10 | 9 |
|
11 | 10 | from ..constants import ( |
|
19 | 18 | ) |
20 | 19 | from ..exceptions import MessageError, NodeError, NodeTimeout, StickError, StickTimeout |
21 | 20 | from ..messages.responses import PlugwiseResponse, StickResponse, StickResponseType |
22 | | -from . import PlugwiseMessage |
| 21 | +from . import PlugwiseMessage, Priority |
23 | 22 | from .properties import ( |
24 | 23 | DateTime, |
25 | 24 | Int, |
|
34 | 33 | _LOGGER = logging.getLogger(__name__) |
35 | 34 |
|
36 | 35 |
|
37 | | -class Priority(int, Enum): |
38 | | - """Message priority levels for USB-stick message requests.""" |
39 | | - |
40 | | - CANCEL = 0 |
41 | | - HIGH = 1 |
42 | | - MEDIUM = 2 |
43 | | - LOW = 3 |
44 | | - |
45 | | - |
46 | 36 | class PlugwiseRequest(PlugwiseMessage): |
47 | 37 | """Base class for request messages to be send from by USB-Stick.""" |
48 | 38 |
|
49 | 39 | arguments: list = [] |
50 | | - priority: Priority = Priority.MEDIUM |
51 | 40 |
|
52 | 41 | def __init__( |
53 | 42 | self, |
@@ -260,38 +249,6 @@ def add_send_attempt(self): |
260 | 249 | """Increase the number of retries.""" |
261 | 250 | self._send_counter += 1 |
262 | 251 |
|
263 | | - def __gt__(self, other: PlugwiseRequest) -> bool: |
264 | | - """Greater than.""" |
265 | | - if self.priority.value == other.priority.value: |
266 | | - return self.timestamp > other.timestamp |
267 | | - if self.priority.value < other.priority.value: |
268 | | - return True |
269 | | - return False |
270 | | - |
271 | | - def __lt__(self, other: PlugwiseRequest) -> bool: |
272 | | - """Less than.""" |
273 | | - if self.priority.value == other.priority.value: |
274 | | - return self.timestamp < other.timestamp |
275 | | - if self.priority.value > other.priority.value: |
276 | | - return True |
277 | | - return False |
278 | | - |
279 | | - def __ge__(self, other: PlugwiseRequest) -> bool: |
280 | | - """Greater than or equal.""" |
281 | | - if self.priority.value == other.priority.value: |
282 | | - return self.timestamp >= other.timestamp |
283 | | - if self.priority.value < other.priority.value: |
284 | | - return True |
285 | | - return False |
286 | | - |
287 | | - def __le__(self, other: PlugwiseRequest) -> bool: |
288 | | - """Less than or equal.""" |
289 | | - if self.priority.value == other.priority.value: |
290 | | - return self.timestamp <= other.timestamp |
291 | | - if self.priority.value > other.priority.value: |
292 | | - return True |
293 | | - return False |
294 | | - |
295 | 252 |
|
296 | 253 | class StickNetworkInfoRequest(PlugwiseRequest): |
297 | 254 | """Request network information. |
|
0 commit comments