5
5
import logging
6
6
import socket
7
7
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
+ )
19
14
20
15
LOGGER = logging .getLogger ("Luxtronik.Discover" )
21
16
@@ -35,9 +30,7 @@ def discover() -> list[tuple[str, int | None]]:
35
30
36
31
# send AIT magic broadcast packet
37
32
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 ())
41
34
42
35
while True :
43
36
try :
@@ -50,9 +43,7 @@ def discover() -> list[tuple[str, int | None]]:
50
43
# if the response starts with the magic nonsense
51
44
if res .startswith (LUXTRONIK_DISCOVERY_RESPONSE_PREFIX ):
52
45
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 ))
56
47
try :
57
48
res_port : int | None = int (res_list [2 ])
58
49
if res_port is None or res_port < 1 or res_port > 65535 :
0 commit comments