26
26
# pylint: disable=unused-argument, too-many-instance-attributes, too-many-locals
27
27
28
28
# <protocol>://<gatewayId>/<deviceAddress>[#<subsystemId>]
29
- DEVICE_URL_RE = r"(?P<protocol>.+)://(?P<gatewayId>\d{4}-\d{4}-\d{4} )/(?P<deviceAddress>[^#]+)(#(?P<subsystemId>\d+))?"
29
+ DEVICE_URL_RE = r"(?P<protocol>.+)://(?P<gatewayId>[^/]+ )/(?P<deviceAddress>[^#]+)(#(?P<subsystemId>\d+))?"
30
30
31
31
32
32
@define (init = False , kw_only = True )
@@ -144,8 +144,8 @@ class Device:
144
144
enabled : bool
145
145
label : str = field (repr = obfuscate_string )
146
146
device_url : str = field (repr = obfuscate_id )
147
- gateway_id : str = field (repr = obfuscate_id )
148
- device_address : str = field (repr = obfuscate_id )
147
+ gateway_id : str | None = field (repr = obfuscate_id )
148
+ device_address : str | None = field (repr = obfuscate_id )
149
149
subsystem_id : int | None = None
150
150
is_sub_device : bool = False
151
151
controllable_name : str
@@ -156,7 +156,7 @@ class Device:
156
156
states : States
157
157
type : ProductType
158
158
place_oid : str | None = None
159
- protocol : Protocol = field (init = False , repr = False )
159
+ protocol : Protocol | None = field (init = False , repr = False )
160
160
161
161
def __init__ (
162
162
self ,
@@ -190,12 +190,15 @@ def __init__(
190
190
self .type = ProductType (type )
191
191
self .place_oid = place_oid
192
192
193
- # Split < protocol>://<gatewayId>/<deviceAddress>[#<subsystemId>] into multiple variables
194
- match = re . search ( DEVICE_URL_RE , device_url )
195
-
193
+ self . protocol = None
194
+ self . gateway_id = None
195
+ self . device_address = None
196
196
self .subsystem_id = None
197
197
self .is_sub_device = False
198
198
199
+ # Split <protocol>://<gatewayId>/<deviceAddress>[#<subsystemId>] into multiple variables
200
+ match = re .search (DEVICE_URL_RE , device_url )
201
+
199
202
if match :
200
203
self .protocol = Protocol (match .group ("protocol" ))
201
204
self .gateway_id = match .group ("gatewayId" )
0 commit comments