3131pw_requests = importlib .import_module ("plugwise_usb.messages.requests" )
3232pw_responses = importlib .import_module ("plugwise_usb.messages.responses" )
3333pw_msg_properties = importlib .import_module ("plugwise_usb.messages.properties" )
34- pw_userdata = importlib .import_module ("stick_pair_data" )
3534pw_node = importlib .import_module ("plugwise_usb.nodes.node" )
3635pw_circle = importlib .import_module ("plugwise_usb.nodes.circle" )
3736pw_sed = importlib .import_module ("plugwise_usb.nodes.sed" )
4544_LOGGER = logging .getLogger (__name__ )
4645_LOGGER .setLevel (logging .DEBUG )
4746
47+ RESPONSE_MESSAGES = {
48+ b"\x05 \x05 \x03 \x03 0001CAAB\r \n " : (
49+ "Stick network info request" ,
50+ b"000000C1" , # Success ack
51+ b"0002" # response msg_id
52+ + b"0123456789012345" # stick-mac
53+ + b"0F" # channel
54+ + b"FFFFFFFFFFFFFFFF"
55+ + b"0698765432101234" # 06 + plus-device mac
56+ + b"FFFFFFFFFFFFFFFF"
57+ + b"0698765432101234" # 06 + plus-device mac
58+ + b"1606" # pan_id
59+ + b"01" , # index
60+ ),
61+ b"\x05 \x05 \x03 \x03 000AB43C\r \n " : (
62+ "STICK INIT" ,
63+ b"000000C1" , # Success ack
64+ b"0011" # msg_id
65+ + b"0123456789012345" # stick mac
66+ + b"00" # unknown1
67+ + b"00" , # network_is_offline
68+ ),
69+ b"\x05 \x05 \x03 \x03 00040000000000000000000098765432101234\r \n " : (
70+ "Pair request of plus-device 0098765432101234" ,
71+ b"000000C1" , # Success ack
72+ b"0005" # response msg_id
73+ + b"00" # existing
74+ + b"01" , # allowed
75+ ),
76+ b"\x05 \x05 \x03 \x03 00230123456789012345A0EC\r \n " : (
77+ "Node Info of stick 0123456789012345" ,
78+ b"000000C1" , # Success ack
79+ b"0024" # msg_id
80+ + b"0123456789012345" # mac
81+ + b"00000000" # datetime
82+ + b"00000000" # log address 0
83+ + b"00" # relay
84+ + b"80" # hz
85+ + b"653907008512" # hw_ver
86+ + b"4E0843A9" # fw_ver
87+ + b"00" , # node_type (Stick)
88+ ),
89+ }
90+
91+ SECOND_RESPONSE_MESSAGES = {
92+ b"\x05 \x05 \x03 \x03 000D55555555555555555E46\r \n " : (
93+ "ping reply for 5555555555555555" ,
94+ b"000000C1" , # Success ack
95+ b"000E"
96+ + b"5555555555555555" # mac
97+ + b"44" # rssi in
98+ + b"33" # rssi out
99+ + b"0055" , # roundtrip
100+ )
101+ }
48102
49103def inc_seq_id (seq_id : bytes | None ) -> bytes :
50104 """Increment sequence id."""
@@ -88,8 +142,8 @@ def __init__(
88142 self ._first_response = test_data
89143 self ._second_response = test_data
90144 if test_data is None :
91- self ._first_response = pw_userdata . RESPONSE_MESSAGES
92- self ._second_response = pw_userdata . SECOND_RESPONSE_MESSAGES
145+ self ._first_response = RESPONSE_MESSAGES
146+ self ._second_response = SECOND_RESPONSE_MESSAGES
93147 self .random_extra_byte = 0
94148 self ._closing = False
95149
@@ -107,7 +161,7 @@ def write(self, data: bytes) -> None:
107161 if log is None and self ._first_response is not None :
108162 log , ack , response = self ._first_response .get (data , (None , None , None ))
109163 if log is None :
110- resp = pw_userdata . PARTLY_RESPONSE_MESSAGES .get (
164+ resp = PARTLY_RESPONSE_MESSAGES .get (
111165 data [:24 ], (None , None , None )
112166 )
113167 if resp is None :
@@ -360,6 +414,54 @@ async def dummy_fn(self, request: pw_requests.PlugwiseRequest, test: bool) -> No
360414 # await stick.initialize()
361415 # await stick.disconnect()
362416
417+ RESPONSE_MESSAGES = {
418+ b"\x05 \x05 \x03 \x03 0001CAAB\r \n " : (
419+ "Stick network info request" ,
420+ b"000000C1" , # Success ack
421+ b"0002" # response msg_id
422+ + b"0123456789012345" # stick-mac
423+ + b"0F" # channel
424+ + b"FFFFFFFFFFFFFFFF"
425+ + b"FF98765432101234" # 06 + plus-device mac
426+ + b"FFFFFFFFFFFFFFFF"
427+ + b"FF98765432101234" # 06 + plus-device mac
428+ + b"04FF" # pan_id
429+ + b"01" , # index
430+ ),
431+ b"\x05 \x05 \x03 \x03 000AB43C\r \n " : (
432+ "STICK INIT" ,
433+ b"000000C1" , # Success ack
434+ b"0011" # msg_id
435+ + b"0123456789012345" # stick mac
436+ + b"00" # unknown1
437+ + b"01" # network_is_online
438+ + b"FF98765432101234"
439+ + b"04FF"
440+ + b"FF" ,
441+ ),
442+ b"\x05 \x05 \x03 \x03 00040000000000000000000098765432101234\r \n " : (
443+ "Pair request of plus-device 0098765432101234" ,
444+ b"000000C1" , # Success ack
445+ b"0005" # response msg_id
446+ + b"00" # existing
447+ + b"01" , # allowed
448+ ),
449+ b"\x05 \x05 \x03 \x03 00230123456789012345A0EC\r \n " : (
450+ "Node Info of stick 0123456789012345" ,
451+ b"000000C1" , # Success ack
452+ b"0024" # msg_id
453+ + b"0123456789012345" # mac
454+ + b"00000000" # datetime
455+ + b"00000000" # log address 0
456+ + b"00" # relay
457+ + b"80" # hz
458+ + b"653907008512" # hw_ver
459+ + b"4E0843A9" # fw_ver
460+ + b"00" , # node_type (Stick)
461+ ),
462+ }
463+
464+
363465 @pytest .mark .asyncio
364466 async def test_pair_plus (self , monkeypatch : pytest .MonkeyPatch ) -> None :
365467 """Test pairing a plus-device."""
0 commit comments