Add and improve fridge
This commit is contained in:
		@@ -295,6 +295,15 @@ class HonAppliance:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
        return result.replace(self.mac_address, "xx-xx-xx-xx-xx-xx")
 | 
					        return result.replace(self.mac_address, "xx-xx-xx-xx-xx-xx")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def sync_command(self, main, target=None) -> None:
 | 
				
			||||||
 | 
					        base: HonCommand = self.commands.get(main)
 | 
				
			||||||
 | 
					        for command, data in self.commands.items():
 | 
				
			||||||
 | 
					            if command == main or target and command not in target:
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
 | 
					            for name, parameter in data.parameters.items():
 | 
				
			||||||
 | 
					                if base_value := base.parameters.get(name):
 | 
				
			||||||
 | 
					                    parameter.value = base_value.value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class HonApplianceTest(HonAppliance):
 | 
					class HonApplianceTest(HonAppliance):
 | 
				
			||||||
    def __init__(self, name):
 | 
					    def __init__(self, name):
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								pyhon/appliances/ref.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								pyhon/appliances/ref.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					from pyhon.parameter.fixed import HonParameterFixed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Appliance:
 | 
				
			||||||
 | 
					    def __init__(self, appliance):
 | 
				
			||||||
 | 
					        self.parent = appliance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def data(self, data):
 | 
				
			||||||
 | 
					        if data["attributes"]["parameters"]["holidayMode"] == "1":
 | 
				
			||||||
 | 
					            data["modeZ1"] = "holiday"
 | 
				
			||||||
 | 
					        elif data["attributes"]["parameters"]["intelligenceMode"] == "1":
 | 
				
			||||||
 | 
					            data["modeZ1"] = "auto_set"
 | 
				
			||||||
 | 
					        elif data["attributes"]["parameters"]["quickModeZ1"] == "1":
 | 
				
			||||||
 | 
					            data["modeZ1"] = "super_cool"
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            data["modeZ1"] = "no_mode"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if data["attributes"]["parameters"]["quickModeZ2"] == "1":
 | 
				
			||||||
 | 
					            data["modeZ2"] = "super_freeze"
 | 
				
			||||||
 | 
					        elif data["attributes"]["parameters"]["intelligenceMode"] == "1":
 | 
				
			||||||
 | 
					            data["modeZ2"] = "auto_set"
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            data["modeZ2"] = "no_mode"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def settings(self, settings):
 | 
				
			||||||
 | 
					        return settings
 | 
				
			||||||
@@ -48,7 +48,7 @@ class HonCommand:
 | 
				
			|||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def api(self) -> "HonAPI":
 | 
					    def api(self) -> "HonAPI":
 | 
				
			||||||
        if self._api is None:
 | 
					        if self._api is None:
 | 
				
			||||||
            raise exceptions.NoAuthenticationException
 | 
					            raise exceptions.NoAuthenticationException("Missing hOn login")
 | 
				
			||||||
        return self._api
 | 
					        return self._api
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@ API_KEY = "GRCqFhC6Gk@ikWXm1RmnSmX1cm,MxY-configuration"
 | 
				
			|||||||
APP = "hon"
 | 
					APP = "hon"
 | 
				
			||||||
# All seen id's (different accounts, different devices) are the same, so I guess this hash is static
 | 
					# All seen id's (different accounts, different devices) are the same, so I guess this hash is static
 | 
				
			||||||
CLIENT_ID = "3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9.HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6"
 | 
					CLIENT_ID = "3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9.HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6"
 | 
				
			||||||
APP_VERSION = "1.53.7"
 | 
					APP_VERSION = "2.0.9"
 | 
				
			||||||
OS_VERSION = 31
 | 
					OS_VERSION = 31
 | 
				
			||||||
OS = "android"
 | 
					OS = "android"
 | 
				
			||||||
DEVICE_MODEL = "exynos9820"
 | 
					DEVICE_MODEL = "exynos9820"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,11 @@ class HonParameter:
 | 
				
			|||||||
    def value(self) -> str | float:
 | 
					    def value(self) -> str | float:
 | 
				
			||||||
        return self._value if self._value is not None else "0"
 | 
					        return self._value if self._value is not None else "0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @value.setter
 | 
				
			||||||
 | 
					    def value(self, value: str | float) -> None:
 | 
				
			||||||
 | 
					        self._value = value
 | 
				
			||||||
 | 
					        self.check_trigger(value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def intern_value(self) -> str | float:
 | 
					    def intern_value(self) -> str | float:
 | 
				
			||||||
        return str(self._value) if self._value is not None else ""
 | 
					        return str(self._value) if self._value is not None else ""
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,11 +37,11 @@ class HonParameterRange(HonParameter):
 | 
				
			|||||||
        return self._step
 | 
					        return self._step
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def value(self) -> float:
 | 
					    def value(self) -> str | float:
 | 
				
			||||||
        return self._value if self._value is not None else self._min
 | 
					        return self._value if self._value is not None else self._min
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @value.setter
 | 
					    @value.setter
 | 
				
			||||||
    def value(self, value: float) -> None:
 | 
					    def value(self, value: str | float) -> None:
 | 
				
			||||||
        value = str_to_float(value)
 | 
					        value = str_to_float(value)
 | 
				
			||||||
        if self._min <= value <= self._max and not (value - self._min) % self._step:
 | 
					        if self._min <= value <= self._max and not (value - self._min) % self._step:
 | 
				
			||||||
            self._value = value
 | 
					            self._value = value
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
									
									
									
									
								
							@@ -7,7 +7,7 @@ with open("README.md", "r") as f:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
setup(
 | 
					setup(
 | 
				
			||||||
    name="pyhOn",
 | 
					    name="pyhOn",
 | 
				
			||||||
    version="0.11.1",
 | 
					    version="0.11.2",
 | 
				
			||||||
    author="Andre Basche",
 | 
					    author="Andre Basche",
 | 
				
			||||||
    description="Control hOn devices with python",
 | 
					    description="Control hOn devices with python",
 | 
				
			||||||
    long_description=long_description,
 | 
					    long_description=long_description,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user