@@ -38,6 +38,42 @@ class Destination(str, Enum):
3838 DEHUMIDIFIER = "DH"
3939
4040
41+ # Define model mappings as a class attribute after the enum class is created
42+ Destination .MODEL_MAPPINGS = {
43+ "Husky" : Destination .DEHUMIDIFIER ,
44+ # Add more model mappings here as they are discovered
45+ }
46+
47+
48+ def _add_from_appliance_type ():
49+ @classmethod
50+ def from_appliance_type (cls , appliance_type : str ) -> 'Destination' :
51+ """
52+ Maps known model names to their corresponding destination types.
53+ Falls back to direct enum lookup for backward compatibility.
54+
55+ :param appliance_type: The model name from the appliance data
56+ :return: The appropriate Destination enum value
57+ :raises ValueError: If the model name is not recognized
58+ """
59+ # Check if it's a known model name first
60+ if appliance_type in cls .MODEL_MAPPINGS :
61+ return cls .MODEL_MAPPINGS [appliance_type ]
62+
63+ # Fall back to direct enum lookup for backward compatibility
64+ try :
65+ return cls (appliance_type )
66+ except ValueError :
67+ raise ValueError (f"'{ appliance_type } ' is not a recognized model name or destination type. "
68+ f"Known destinations: { list (cls )} , "
69+ f"Known models: { list (cls .MODEL_MAPPINGS .keys ())} " )
70+
71+ Destination .from_appliance_type = from_appliance_type
72+
73+
74+ _add_from_appliance_type ()
75+
76+
4177class Setting (str , Enum ):
4278 """
4379 Writeable settings that are known valid names of Components.
@@ -106,7 +142,7 @@ def __init__(self, args: Dict):
106142 self .appliance_id : str = args ['applianceId' ]
107143 self .appliance_type : str = args ['applianceData' ]['modelName' ]
108144 self .nickname : str = args ['applianceData' ]['applianceName' ]
109- self .destination = Destination (self .appliance_type )
145+ self .destination = Destination . from_appliance_type (self .appliance_type )
110146
111147
112148class Component :
0 commit comments