1010
1111from homeassistant .util .json import json_loads , json_loads_object
1212
13- from .const import LOGGER , DPCode , DPType
13+ from .const import LOGGER , DPType
1414from .util import parse_dptype , remap_value
1515
1616# Dictionary to track logged warnings to avoid spamming logs
@@ -39,11 +39,11 @@ class TypeInformation:
3939 As provided by the SDK, from `device.function` / `device.status_range`.
4040 """
4141
42- dpcode : DPCode
42+ dpcode : str
4343 type_data : str | None = None
4444
4545 @classmethod
46- def from_json (cls , dpcode : DPCode , type_data : str ) -> Self | None :
46+ def from_json (cls , dpcode : str , type_data : str ) -> Self | None :
4747 """Load JSON string and return a TypeInformation object."""
4848 return cls (dpcode = dpcode , type_data = type_data )
4949
@@ -102,7 +102,7 @@ def remap_value_from(
102102 return remap_value (value , from_min , from_max , self .min , self .max , reverse )
103103
104104 @classmethod
105- def from_json (cls , dpcode : DPCode , type_data : str ) -> Self | None :
105+ def from_json (cls , dpcode : str , type_data : str ) -> Self | None :
106106 """Load JSON string and return a IntegerTypeData object."""
107107 if not (parsed := cast (dict [str , Any ] | None , json_loads_object (type_data ))):
108108 return None
@@ -125,7 +125,7 @@ class BitmapTypeInformation(TypeInformation):
125125 label : list [str ]
126126
127127 @classmethod
128- def from_json (cls , dpcode : DPCode , type_data : str ) -> Self | None :
128+ def from_json (cls , dpcode : str , type_data : str ) -> Self | None :
129129 """Load JSON string and return a BitmapTypeInformation object."""
130130 if not (parsed := json_loads_object (type_data )):
131131 return None
@@ -143,7 +143,7 @@ class EnumTypeData(TypeInformation):
143143 range : list [str ]
144144
145145 @classmethod
146- def from_json (cls , dpcode : DPCode , type_data : str ) -> Self | None :
146+ def from_json (cls , dpcode : str , type_data : str ) -> Self | None :
147147 """Load JSON string and return a EnumTypeData object."""
148148 if not (parsed := json_loads_object (type_data )):
149149 return None
@@ -175,7 +175,7 @@ class DPCodeWrapper:
175175 native_unit : str | None = None
176176 suggested_unit : str | None = None
177177
178- def __init__ (self , dpcode : DPCode ) -> None :
178+ def __init__ (self , dpcode : str ) -> None :
179179 """Init DPCodeWrapper."""
180180 self .dpcode = dpcode
181181
@@ -222,7 +222,7 @@ class DPCodeTypeInformationWrapper[T: TypeInformation](DPCodeWrapper):
222222 DPTYPE : DPType
223223 type_information : T
224224
225- def __init__ (self , dpcode : DPCode , type_information : T ) -> None :
225+ def __init__ (self , dpcode : str , type_information : T ) -> None :
226226 """Init DPCodeWrapper."""
227227 super ().__init__ (dpcode )
228228 self .type_information = type_information
@@ -231,7 +231,7 @@ def __init__(self, dpcode: DPCode, type_information: T) -> None:
231231 def find_dpcode (
232232 cls ,
233233 device : CustomerDevice ,
234- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
234+ dpcodes : str | tuple [str , ...] | None ,
235235 * ,
236236 prefer_function : bool = False ,
237237 ) -> Self | None :
@@ -340,7 +340,7 @@ class DPCodeIntegerWrapper(DPCodeTypeInformationWrapper[IntegerTypeData]):
340340
341341 DPTYPE = DPType .INTEGER
342342
343- def __init__ (self , dpcode : DPCode , type_information : IntegerTypeData ) -> None :
343+ def __init__ (self , dpcode : str , type_information : IntegerTypeData ) -> None :
344344 """Init DPCodeIntegerWrapper."""
345345 super ().__init__ (dpcode , type_information )
346346 self .native_unit = type_information .unit
@@ -380,7 +380,7 @@ def read_device_status(self, device: CustomerDevice) -> str | None:
380380class DPCodeBitmapBitWrapper (DPCodeWrapper ):
381381 """Simple wrapper for a specific bit in bitmap values."""
382382
383- def __init__ (self , dpcode : DPCode , mask : int ) -> None :
383+ def __init__ (self , dpcode : str , mask : int ) -> None :
384384 """Init DPCodeBitmapWrapper."""
385385 super ().__init__ (dpcode )
386386 self ._mask = mask
@@ -395,7 +395,7 @@ def read_device_status(self, device: CustomerDevice) -> bool | None:
395395 def find_dpcode (
396396 cls ,
397397 device : CustomerDevice ,
398- dpcodes : str | DPCode | tuple [DPCode , ...],
398+ dpcodes : str | tuple [str , ...],
399399 * ,
400400 bitmap_key : str ,
401401 ) -> Self | None :
@@ -412,7 +412,7 @@ def find_dpcode(
412412@overload
413413def find_dpcode (
414414 device : CustomerDevice ,
415- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
415+ dpcodes : str | tuple [str , ...] | None ,
416416 * ,
417417 prefer_function : bool = False ,
418418 dptype : Literal [DPType .BITMAP ],
@@ -422,7 +422,7 @@ def find_dpcode(
422422@overload
423423def find_dpcode (
424424 device : CustomerDevice ,
425- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
425+ dpcodes : str | tuple [str , ...] | None ,
426426 * ,
427427 prefer_function : bool = False ,
428428 dptype : Literal [DPType .ENUM ],
@@ -432,7 +432,7 @@ def find_dpcode(
432432@overload
433433def find_dpcode (
434434 device : CustomerDevice ,
435- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
435+ dpcodes : str | tuple [str , ...] | None ,
436436 * ,
437437 prefer_function : bool = False ,
438438 dptype : Literal [DPType .INTEGER ],
@@ -442,7 +442,7 @@ def find_dpcode(
442442@overload
443443def find_dpcode (
444444 device : CustomerDevice ,
445- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
445+ dpcodes : str | tuple [str , ...] | None ,
446446 * ,
447447 prefer_function : bool = False ,
448448 dptype : Literal [DPType .BOOLEAN , DPType .JSON , DPType .RAW ],
@@ -451,7 +451,7 @@ def find_dpcode(
451451
452452def find_dpcode (
453453 device : CustomerDevice ,
454- dpcodes : str | DPCode | tuple [DPCode , ...] | None ,
454+ dpcodes : str | tuple [str , ...] | None ,
455455 * ,
456456 prefer_function : bool = False ,
457457 dptype : DPType ,
@@ -463,9 +463,7 @@ def find_dpcode(
463463 if dpcodes is None :
464464 return None
465465
466- if isinstance (dpcodes , str ):
467- dpcodes = (DPCode (dpcodes ),)
468- elif not isinstance (dpcodes , tuple ):
466+ if not isinstance (dpcodes , tuple ):
469467 dpcodes = (dpcodes ,)
470468
471469 lookup_tuple = (
0 commit comments