diff --git a/custom_components/xiaomi_miot_raw/__init__.py b/custom_components/xiaomi_miot_raw/__init__.py index df4c1d3..abd2bec 100644 --- a/custom_components/xiaomi_miot_raw/__init__.py +++ b/custom_components/xiaomi_miot_raw/__init__.py @@ -283,12 +283,14 @@ def setup_cloud(self, hass) -> tuple: self._mapping = mappingnew self._ctrl_params = config.get(CONF_CONTROL_PARAMS) or {} + self._max_properties = 10 if type(self._ctrl_params) == str: self._ctrl_params = json.loads(self._ctrl_params) if not type(self._ctrl_params) == OrderedDict: paramsnew = {} + self._max_properties = self._ctrl_params.pop('max_properties', 10) for k,v in self._ctrl_params.items(): for kk,vv in v.items(): paramsnew[f"{k[:10]}_{kk}"] = vv @@ -595,8 +597,8 @@ def pre_process_data(key, value): try: if not self._cloud: response = await self.hass.async_add_job( - self._device.get_properties_for_mapping - ) + partial(self._device.get_properties_for_mapping, max_properties=self._max_properties) + ) self._available = True statedict={} @@ -1077,7 +1079,7 @@ async def async_generic_setup_platform( di['model'], di['mac'], di['fw_version'], - "" + "N/A for Cloud Mode" ) if main_mi_type in main_class_dict: device = main_class_dict[main_mi_type](miio_device, config, device_info, hass, main_mi_type) diff --git a/custom_components/xiaomi_miot_raw/deps/special_devices.py b/custom_components/xiaomi_miot_raw/deps/special_devices.py index d66e2b7..4893aa3 100644 --- a/custom_components/xiaomi_miot_raw/deps/special_devices.py +++ b/custom_components/xiaomi_miot_raw/deps/special_devices.py @@ -69,6 +69,11 @@ "mapping": {"fan": {"switch_status": {"siid": 2, "piid": 1}, "speed": {"siid": 2, "piid": 2}, "mode": {"siid": 2, "piid": 3}, "oscillate": {"siid": 2, "piid": 4}, "horizontal_angle": {"siid": 2, "piid": 5}, "stepless_speed": {"siid": 8, "piid": 1}, "motor_control": {"siid": 6, "piid": 1}}, "indicator_light": {"switch_status": {"siid": 4, "piid": 1}}, "physical_controls_locked": {"physical_controls_locked": {"siid": 7, "piid": 1}}, "a_l": {"off_delay_time_toggle": {"siid": 3, "aiid": 1}, "dm_service_toggle_mode": {"siid": 8, "aiid": 1}, "dm_service_loop_gear": {"siid": 8, "aiid": 2}}}, "params": {"fan": {"switch_status": {"power_on": True, "power_off": False}, "speed": {"Level1": 1, "Level2": 2, "Level3": 3, "Level4": 4}, "mode": {"Straight Wind": 0, "Natural Wind": 1}, "oscillate": {"True": True, "False": False}, "horizontal_angle": {"access": 7, "format": "uint16", "unit": None, "value_list": {"30": 30, "60": 60, "90": 90, "120": 120, "140": 140}}, "main": True, "stepless_speed": {"value_range": [1, 100, 1]}, "motor_control": {"left": 1, "right": 2}}, "indicator_light": {"switch_status": {"power_on": True, "power_off": False}}, "physical_controls_locked": {"enabled": False}} }, + "cgllc.airm.cgdn1": { + "device_type": ['sensor', 'fan'], + "mapping": {"environment": {"relative_humidity": {"siid": 3, "piid": 1}, "pm2_5_density": {"siid": 3, "piid": 4}, "pm10_density": {"siid": 3, "piid": 5}, "temperature": {"siid": 3, "piid": 7}, "co2_density": {"siid": 3, "piid": 8}}, "settings": {"start_time": {"siid": 9, "piid": 2}, "end_time": {"siid": 9, "piid": 3}, "monitoring_frequency": {"siid": 9, "piid": 4}, "screen_off": {"siid": 9, "piid": 5}, "device_off": {"siid": 9, "piid": 6}, "tempature_unit": {"siid": 9, "piid": 7}}, "a_l": {"settings_set_start_time": {"siid": 9, "aiid": 2}, "settings_set_end_time": {"siid": 9, "aiid": 3}, "settings_set_frequency": {"siid": 9, "aiid": 4}, "settings_set_screen_off": {"siid": 9, "aiid": 5}, "settings_set_device_off": {"siid": 9, "aiid": 6}, "settings_set_temp_unit": {"siid": 9, "aiid": 7}}}, + "params": {"environment": {"relative_humidity": {"access": 5, "format": "uint8", "unit": "percentage", "value_range": [0, 100, 1]}, "pm2_5_density": {"access": 5, "format": "uint16", "unit": "\u03bcg/m3", "value_range": [0, 1000, 1]}, "pm10_density": {"access": 5, "format": "uint16", "unit": "\u03bcg/m3", "value_range": [0, 1000, 1]}, "temperature": {"access": 5, "format": "float", "unit": "celsius", "value_range": [-30, 100, 1e-05]}, "co2_density": {"access": 5, "format": "uint16", "unit": "ppm", "value_range": [0, 9999, 1]}, "main": True}, "settings": {"start_time": {"access": 7, "format": "int32", "value_range": [0, 2147483647, 1]}, "end_time": {"access": 7, "format": "int32", "value_range": [0, 2147483647, 1]}, "monitoring_frequency": {"access": 7, "format": "uint16", "unit": "seconds", "value_list": {"Second": 600, "Null": 0}}, "screen_off": {"access": 7, "format": "uint16", "unit": "seconds", "value_list": {"Second": 300, "Null": 0}}, "device_off": {"access": 7, "format": "int8", "unit": "minutes", "value_list": {"Minute": 60, "Null": 0}}, "tempature_unit": {"access": 7, "format": "string"}}, 'max_properties': 8} + }, }