Skip to content

Commit c2dbd82

Browse files
committed
moved contsants from discover into constants file
1 parent 0b2d918 commit c2dbd82

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

luxtronik/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@
1212

1313
LUXTRONIK_SOCKET_READ_SIZE_INTEGER = 4
1414
LUXTRONIK_SOCKET_READ_SIZE_CHAR = 1
15+
16+
# List of ports that are known to respond to discovery packets
17+
LUXTRONIK_DISCOVERY_PORTS = [4444, 47808]
18+
19+
# Time (in seconds) to wait for response after sending discovery broadcast
20+
LUXTRONIK_DISCOVERY_TIMEOUT = 2
21+
22+
# Content of packet that will be sent for discovering heat pumps
23+
LUXTRONIK_DISCOVERY_MAGIC_PACKET = "2000;111;1;\x00"
24+
25+
# Content of response that is contained in responses to discovery broadcast
26+
LUXTRONIK_DISCOVERY_RESPONSE_PREFIX = "2500;111;"

luxtronik/discover.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
import logging
66
import socket
77

8-
# List of ports that are known to respond to discovery packets
9-
LUXTRONIK_DISCOVERY_PORTS = [4444, 47808]
10-
11-
# Time (in seconds) to wait for response after sending discovery broadcast
12-
LUXTRONIK_DISCOVERY_TIMEOUT = 2
13-
14-
# Content of packet that will be sent for discovering heat pumps
15-
LUXTRONIK_DISCOVERY_MAGIC_PACKET = "2000;111;1;\x00"
16-
17-
# Content of response that is contained in responses to discovery broadcast
18-
LUXTRONIK_DISCOVERY_RESPONSE_PREFIX = "2500;111;"
8+
from constants import (
9+
LUXTRONIK_DISCOVERY_PORTS,
10+
LUXTRONIK_DISCOVERY_TIMEOUT,
11+
LUXTRONIK_DISCOVERY_MAGIC_PACKET,
12+
LUXTRONIK_DISCOVERY_RESPONSE_PREFIX,
13+
)
1914

2015
LOGGER = logging.getLogger("Luxtronik.Discover")
2116

@@ -35,9 +30,7 @@ def discover() -> list[tuple[str, int | None]]:
3530

3631
# send AIT magic broadcast packet
3732
server.sendto(LUXTRONIK_DISCOVERY_MAGIC_PACKET.encode(), ("<broadcast>", port))
38-
LOGGER.debug(
39-
"Sending broadcast request %s", LUXTRONIK_DISCOVERY_MAGIC_PACKET.encode()
40-
)
33+
LOGGER.debug("Sending broadcast request %s", LUXTRONIK_DISCOVERY_MAGIC_PACKET.encode())
4134

4235
while True:
4336
try:
@@ -50,9 +43,7 @@ def discover() -> list[tuple[str, int | None]]:
5043
# if the response starts with the magic nonsense
5144
if res.startswith(LUXTRONIK_DISCOVERY_RESPONSE_PREFIX):
5245
res_list = res.split(";")
53-
LOGGER.debug(
54-
"Received response from %s %s", ip_address, str(res_list)
55-
)
46+
LOGGER.debug("Received response from %s %s", ip_address, str(res_list))
5647
try:
5748
res_port: int | None = int(res_list[2])
5849
if res_port is None or res_port < 1 or res_port > 65535:

0 commit comments

Comments
 (0)