From c938c3622c87a43de21007df09f9e07f2d0efff3 Mon Sep 17 00:00:00 2001 From: Alone Date: Fri, 24 May 2024 11:41:25 +0800 Subject: [PATCH 01/34] =?UTF-8?q?=F0=9F=AA=AD=20improve=20for=20zhimi.fan.?= =?UTF-8?q?za3/za4=20(#1686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/device_customizes.py | 6 ++++++ custom_components/xiaomi_miot/core/miio2miot_specs.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index c10763565..df11c1bb7 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1624,6 +1624,12 @@ 'brightness_for_on': 0, 'brightness_for_off': 2, }, + 'zhimi.fan.za3': { + 'miot_type': 'urn:miot-spec-v2:device:fan:0000A005:zhimi-za3:3', + }, + 'zhimi.fan.za4': { + 'miot_type': 'urn:miot-spec-v2:device:fan:0000A005:zhimi-za4:3', + }, 'zhimi.fan.*': { 'switch_properties': 'anion,alarm,horizontal_swing,vertical_swing', 'number_properties': 'horizontal_angle,vertical_angle,off_delay', diff --git a/custom_components/xiaomi_miot/core/miio2miot_specs.py b/custom_components/xiaomi_miot/core/miio2miot_specs.py index f8c78260b..20fc6f5d3 100644 --- a/custom_components/xiaomi_miot/core/miio2miot_specs.py +++ b/custom_components/xiaomi_miot/core/miio2miot_specs.py @@ -2754,6 +2754,16 @@ def cbk(prop, params, props, **kwargs): 'template': '{{ 1 if value|int(0) > 0 else 0 }}', 'set_template': '{{ [value|int(0) * 25] }}', }, + 'prop.2.6': { + 'prop': 'speed_level', + 'setter': True, + 'template': '{{ props.natural_level|default(value,true)|int(0) }}', + 'set_template': '{% set nlv = props.natural_level|default(0)|int(0) %}' + '{{ {' + '"method": "set_natural_level" if nlv else "set_speed_level",' + '"params": [value|int(0)],' + '} }}', + }, 'prop.4.1': { 'prop': 'buzzer', 'setter': True, From 3343c8964633ab138e3cbc7eecb00a3cbd906e0d Mon Sep 17 00:00:00 2001 From: Alone Date: Fri, 24 May 2024 11:43:19 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=F0=9F=AA=AD=20improve=20for=20zhimi.fan.?= =?UTF-8?q?za3/za4=20(#1686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index df11c1bb7..9da162ca5 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1626,9 +1626,11 @@ }, 'zhimi.fan.za3': { 'miot_type': 'urn:miot-spec-v2:device:fan:0000A005:zhimi-za3:3', + 'number_select_properties': 'fan_level', }, 'zhimi.fan.za4': { 'miot_type': 'urn:miot-spec-v2:device:fan:0000A005:zhimi-za4:3', + 'number_select_properties': 'fan_level', }, 'zhimi.fan.*': { 'switch_properties': 'anion,alarm,horizontal_swing,vertical_swing', From a14b91d5aaca5153d8228ec6020f30926cc2a21d Mon Sep 17 00:00:00 2001 From: Alone Date: Tue, 4 Jun 2024 11:02:02 +0800 Subject: [PATCH 03/34] =?UTF-8?q?=F0=9F=9B=80=20improve=20for=20opple.bhf?= =?UTF-8?q?=5Flight.acmoto=20(#1698)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 9da162ca5..6546a428f 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1057,6 +1057,13 @@ 'device_class': 'problem', }, + 'opple.bhf_light.acmoto': { + 'exclude_miot_services': 'pair,wifisinr,class_sku,fan_motor', + 'exclude_miot_properties': 'fault', + 'light_services': 'aura_light', + 'number_properties': 'function_countdown.warm,function_countdown.blower,' + 'function_countdown.breath,function_countdown,shutdown', + }, 'opple.light.yrtd': { 'switch_properties': 'night_light,time_display,wake_up_at_night,voice', 'select_properties': 'study_time', From c057c7caa60670700a17c00d0056965c1e6202bc Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 23 Jun 2024 17:47:20 +0800 Subject: [PATCH 04/34] =?UTF-8?q?=F0=9F=94=94=20add=20support=20for=20madv?= =?UTF-8?q?.cateye.mi3iot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 6546a428f..e6f03d81e 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -941,6 +941,13 @@ 'cloud_delay_update': 10, }, + 'madv.cateye.mi3iot': { + 'sensor_properties': 'battery_level', + 'switch_properties': 'eco,motion_detection,alarm,autoreply,fw_autoupgrade,vistpush,motionpush', + 'select_properties': 'night_shot,ringtone,alarm_interval,detection_sensitivity,motionpush_pushtype,videolength,' + 'eco_code,ringer_music', + 'number_properties': 'videodelay,volume', + }, 'mibx5.washer.*': { 'sensor_properties': 'fault,left_time,door_state,run_status,detergent_left_level', 'switch_properties': 'sleep_mode,steam_sterilization,detergent_self_delivery', From 2dfd20d6574eeae9b6352830c352a5c6701cedb1 Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 23 Jun 2024 18:07:18 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=F0=9F=94=94=20add=20support=20for=20madv?= =?UTF-8?q?.cateye.mi3iot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index e6f03d81e..2ac103b9c 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -942,6 +942,7 @@ }, 'madv.cateye.mi3iot': { + 'binary_sensor_properties': 'madv_doorbell.motion_detection', 'sensor_properties': 'battery_level', 'switch_properties': 'eco,motion_detection,alarm,autoreply,fw_autoupgrade,vistpush,motionpush', 'select_properties': 'night_shot,ringtone,alarm_interval,detection_sensitivity,motionpush_pushtype,videolength,' From 4dabb89a5e37ad040bb9a8392eabfe62fafcc32a Mon Sep 17 00:00:00 2001 From: Luca Angemi Date: Sun, 7 Jul 2024 10:31:18 +0200 Subject: [PATCH 06/34] =?UTF-8?q?=F0=9F=94=A7=20fix=20blocking=20call=20(#?= =?UTF-8?q?1729)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index e35b4d434..505cf0f22 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -205,11 +205,14 @@ async def async_setup(hass, hass_config: dict): config = hass_config.get(DOMAIN) or {} await async_reload_integration_config(hass, config) - with open(os.path.dirname(__file__) + '/core/miot_specs_extend.json') as file: - models = json.load(file) or {} - for m, specs in models.items(): - DEVICE_CUSTOMIZES.setdefault(m, {}) - DEVICE_CUSTOMIZES[m]['extend_miot_specs'] = specs + def extend_miot_specs(): + with open(os.path.dirname(__file__) + '/core/miot_specs_extend.json') as file: + models = json.load(file) or {} + for m, specs in models.items(): + DEVICE_CUSTOMIZES.setdefault(m, {}) + DEVICE_CUSTOMIZES[m]['extend_miot_specs'] = specs + + await hass.async_add_executor_job(extend_miot_specs) component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL) hass.data[DOMAIN]['component'] = component @@ -273,10 +276,7 @@ async def async_setup_entry(hass: hass_core.HomeAssistant, config_entry: config_ if not config_entry.update_listeners: config_entry.add_update_listener(async_update_options) - for sd in SUPPORTED_DOMAINS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(config_entry, sd) - ) + await hass.config_entries.async_forward_entry_setups(config_entry, SUPPORTED_DOMAINS) return True From 91bcd1f08ad437ef494287342ee6a18123a0b758 Mon Sep 17 00:00:00 2001 From: Brandon Chen Date: Sun, 7 Jul 2024 16:33:40 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=F0=9F=94=8C=20add=20energy=20for=20cuco.?= =?UTF-8?q?plug.wp12=20(#1748)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/device_customizes.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 2ac103b9c..6122bd73b 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -407,6 +407,23 @@ 'state_class': 'total_increasing', 'device_class': 'energy', 'unit_of_measurement': 'kWh', + }, + 'cuco.plug.wp12': { + 'main_miot_services': 'switch-2', + 'sensor_attributes': 'power_cost_today,power_cost_month', + 'stat_power_cost_key': '11.1' + }, + 'cuco.plug.wp12:power_cost_today': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', + }, + 'cuco.plug.wp12:power_cost_month': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', }, 'cuco.plug.*': { 'main_miot_services': 'switch-2', From 49d72f4161a1612b8d36c7128882c16d3f3f9daf Mon Sep 17 00:00:00 2001 From: whc2001 Date: Sun, 7 Jul 2024 04:36:59 -0400 Subject: [PATCH 08/34] =?UTF-8?q?=F0=9F=94=A7=20fix=20fan=20speed=20settin?= =?UTF-8?q?g=20for=20nwt.derh.wdh318efw1=20(#1726)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/miio2miot_specs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/core/miio2miot_specs.py b/custom_components/xiaomi_miot/core/miio2miot_specs.py index 20fc6f5d3..d7b98a155 100644 --- a/custom_components/xiaomi_miot/core/miio2miot_specs.py +++ b/custom_components/xiaomi_miot/core/miio2miot_specs.py @@ -804,7 +804,7 @@ def cbk(prop, params, props, **kwargs): '["dry_cloth"] if value == 2 else ' '{"method": "set_auto","params": [props.auto]} }}', }, - 'prop.2.3': {'prop': 'fan_st', 'setter': True}, + 'prop.2.3': {'prop': 'fan_st', 'setter': 'set_fan_level'}, 'prop.2.101': {'prop': 'auto', 'setter': True}, 'prop.2.102': {'prop': 'tank_full', 'format': 'onoff'}, 'prop.3.1': {'prop': 'humidity'}, From 8d00385127175c9a3276ffcdb033dc43eaf1fba0 Mon Sep 17 00:00:00 2001 From: Brandon Chen Date: Sun, 7 Jul 2024 16:38:25 +0800 Subject: [PATCH 09/34] =?UTF-8?q?=F0=9F=AA=AD=20improve=20for=20dmaker.fan?= =?UTF-8?q?.p28=20(#1709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 6122bd73b..7e228a36c 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -530,8 +530,9 @@ 'percentage_property': 'prop.2.6', }, 'dmaker.fan.p28': { + 'switch_properties': 'alarm,horizontal_swing,vertical_swing,swing_all,off_to_center', 'percentage_property': 'speed_level', - 'button_properties': 'swing_updown_manual,swing_lr_manual,back_to_center', + 'button_properties': 'swing_updown_manual,swing_lr_manual,back_to_center,start_left,start_right,start_up,start_down', }, 'dmaker.fan.p33': { 'percentage_property': 'prop.2.6', From 9bbc9e20730e562b54990c20a6299ad318f22053 Mon Sep 17 00:00:00 2001 From: Menelao147 <59983324+Menelao147@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:41:31 +0200 Subject: [PATCH 10/34] =?UTF-8?q?=F0=9F=8C=90=20update=20it.json=20(#1624)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/translations/it.json | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/custom_components/xiaomi_miot/translations/it.json b/custom_components/xiaomi_miot/translations/it.json index c2527c5b9..f8b7a29df 100644 --- a/custom_components/xiaomi_miot/translations/it.json +++ b/custom_components/xiaomi_miot/translations/it.json @@ -54,64 +54,6 @@ "model_specified": "Modello dispositivo specificato (opzionale)", "only_main_entity": "Solo entità principali (parent)", "reset_customizes": "Ripristina le opzioni predefinite", - - "binary_sensor_attributes": "Attributi del sensore binario", - "binary_sensor_properties": "Proprietà del sensore binario", - "bind_sensor": "Collega sensore", - "bind_xiaoai": "Collega Xiaoai", - "brightness_for_off": "Luminosità per spegnere", - "brightness_for_on": "Luminosità per accendere", - "button_actions": "Azioni del pulsante", - "button_properties": "Proprietà del pulsante", - "chunk_properties": "Proprietà del chunk", - "close_texts": "close_texts", - "closed_position": "Posizione chiusa", - "cloud_delay_update": "Ritardo aggiornamento cloud", - "coord_type": "Tipo coordinata", - "cover_properties": "Proprietà copertura", - "current_temp_property": "Proprietà temperatura corrente", - "descriptions_for_on": "Descrizione per acceso", - "deviated_position": "Posizione deviazione", - "device_class": "Classe dispositivo", - "disable_location_name": "Disabilita nome località", - "disable_preset_modes": "Disabilita modalità predefinite", - "entity_category": "Categoria entità", - "exclude_miot_properties": "Escludi proprietà miot", - "exclude_miot_services": "Escludi servizi miot", - "exclude_type": "Tipo esclusione", - "fan_services": "Servizi ventilatore", - "feeding_measure": "Misura alimentazione", - "filter_home": "Filtro principale", - "interval_seconds": "Secondi di intervallo", - "light_services": "Servizi luce", - "main_miot_services": "Servizi miot principali", - "miot_did": "Miot did", - "mitv_lan_host": "Host lan mitv", - "motion_stream_slice": "Fetta del flusso di movimento", - "motion_timeout": "Timeout movimento", - "number_properties": "Proprietà numeriche", - "open_texts": "Testi aperti", - "percentage_property": "Proprietà percentuale", - "screenshot_compress": "Compressione screenshot", - "select_properties": "Seleziona proprietà", - "sensor_attributes": "Attributi sensore", - "sensor_properties": "Proprietà sensore", - "sources_via_apps": "Fonti via app", - "sources_via_keycodes": "Fonti via codici chiave", - "speed_property": "Proprietà velocità", - "stat_power_cost_key": "Chiave statistica costo energetico", - "stat_power_cost_type": "Tipo statistica costo energetico", - "state_class": "Classe stato", - "state_property": "Proprietà stato", - "switch_properties": "Proprietà interruttore", - "television_name": "Nome televisione", - "turn_on_hvac": "Accendi HVAC", - "unit_of_measurement": "Unità di misuta", - "value_ratio": "Rapporto valore", - "video_attribute": "Attributo video", - "yeelight_smooth_off": "Yeelight spegnimento graduale", - "yeelight_smooth_on": "Yeelight accensione graduale", - "bool2selects": "Presonalizza opzioni" } } From e986ddbf86b19a71346e98218423eabfd864857c Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 17:09:28 +0800 Subject: [PATCH 11/34] =?UTF-8?q?=F0=9F=9A=BD=20add=20support=20for=20dawn?= =?UTF-8?q?.toilet.02=20(#1736)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 7e228a36c..b12eb42a9 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -476,6 +476,11 @@ 'state_class': '', }, + 'dawn.toilet.02': { + 'button_actions': 'stop_working,fangai,fanquan,paopaowei,chongshui,tunxi,fuxi,honggan,zijie', + 'switch_properties': 'on,auto_flush,foot_sensing,moistening_wall,auto_clamshell', + 'select_properties': 'target_temperature,washing_strength,nozzle_position,sensing_distance', + }, 'deerma.humidifier.jsq4': { 'exclude_miot_services': None, }, From 7dc79fc2cd9f2f7f04a99d8e7200e0ff4b86953f Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 17:37:23 +0800 Subject: [PATCH 12/34] =?UTF-8?q?=E2=8C=9B=20add=20parallel=20updates=20fo?= =?UTF-8?q?r=20switch=20(#1749)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/switch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/xiaomi_miot/switch.py b/custom_components/xiaomi_miot/switch.py index 2ed10b2b4..9c8d905b3 100644 --- a/custom_components/xiaomi_miot/switch.py +++ b/custom_components/xiaomi_miot/switch.py @@ -36,6 +36,7 @@ _LOGGER = logging.getLogger(__name__) DATA_KEY = f'{ENTITY_DOMAIN}.{DOMAIN}' +PARALLEL_UPDATES = 3 # issue#1749 SERVICE_TO_METHOD = {} From 464030438b95f08a5e5b300b90a8244e91634df2 Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 17:51:07 +0800 Subject: [PATCH 13/34] =?UTF-8?q?=F0=9F=94=A7=20fix=20blocking=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/system_health.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/system_health.py b/custom_components/xiaomi_miot/system_health.py index 3548d5869..d63c0e26f 100644 --- a/custom_components/xiaomi_miot/system_health.py +++ b/custom_components/xiaomi_miot/system_health.py @@ -30,8 +30,9 @@ async def system_health_info(hass): api = mic.get_api_url('') if mic else 'https://api.io.mi.com' api_spec = 'https://miot-spec.org/miot-spec-v2/spec/services' + version = await hass.async_add_executor_job(get_manifest, 'version', 'unknown') data = { - 'component_version': get_manifest('version', 'unknown'), + 'component_version': version, 'can_reach_server': system_health.async_check_can_reach_url(hass, api), 'can_reach_spec': system_health.async_check_can_reach_url( hass, api_spec, 'https://home.miot-spec.com/?cant-reach', From 24a752742d074ba1f3dc5f7e004ba0998ac40037 Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 19:13:22 +0800 Subject: [PATCH 14/34] =?UTF-8?q?=E2=8C=9B=20add=20option=20`parallel=5Fup?= =?UTF-8?q?dates`=20(#1749)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/__init__.py | 20 +++++++++++++++++++ .../xiaomi_miot/core/device_customizes.py | 1 + custom_components/xiaomi_miot/switch.py | 1 - 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 505cf0f22..9c7ef98eb 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -843,6 +843,25 @@ def update_custom_scan_interval(self, only_custom=False): self.platform.scan_interval = tim _LOGGER.debug('%s: Update custom scan interval: %s', self.name_model, tim) + def update_custom_parallel_updates(self): + if not self.hass: + return False + if not hasattr(self, '_unique_did'): + return False + num = self.custom_config_integer('parallel_updates', 0) + if not num: + return False + did = self._unique_did + self.hass.data[DOMAIN].setdefault(did, {}) + dcs = self.hass.data[DOMAIN].get(did, {}) + pus = dcs.get('parallel_updates') + if not pus: + pus = asyncio.Semaphore(num) + self.hass.data[DOMAIN][did]['parallel_updates'] = pus + _LOGGER.warning('%s: Update custom parallel updates: %s', self.name_model, num) + self.parallel_updates = pus + return pus + def filter_state_attributes(self, dat: dict): if exl := self.global_config('exclude_state_attributes'): exl = cv.ensure_list(exl) @@ -973,6 +992,7 @@ async def async_added_to_hass(self): await super().async_added_to_hass() if self.platform: self.update_custom_scan_interval() + self.update_custom_parallel_updates() if self.platform.config_entry: eid = self.platform.config_entry.entry_id self._add_entities = self.hass.data[DOMAIN][eid].get('add_entities') or {} diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index b12eb42a9..fcdad3f4e 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -427,6 +427,7 @@ }, 'cuco.plug.*': { 'main_miot_services': 'switch-2', + 'parallel_updates': 3, }, 'cuco.plug.*:electric_current': { 'state_class': 'measurement', diff --git a/custom_components/xiaomi_miot/switch.py b/custom_components/xiaomi_miot/switch.py index 9c8d905b3..2ed10b2b4 100644 --- a/custom_components/xiaomi_miot/switch.py +++ b/custom_components/xiaomi_miot/switch.py @@ -36,7 +36,6 @@ _LOGGER = logging.getLogger(__name__) DATA_KEY = f'{ENTITY_DOMAIN}.{DOMAIN}' -PARALLEL_UPDATES = 3 # issue#1749 SERVICE_TO_METHOD = {} From 40920ce2d367b3ab5bbc87977410ece0822f2fc9 Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 19:17:04 +0800 Subject: [PATCH 15/34] =?UTF-8?q?=E2=8C=9B=20add=20option=20`parallel=5Fup?= =?UTF-8?q?dates`=20(#1749)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 9c7ef98eb..08ddcf0fc 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -858,7 +858,7 @@ def update_custom_parallel_updates(self): if not pus: pus = asyncio.Semaphore(num) self.hass.data[DOMAIN][did]['parallel_updates'] = pus - _LOGGER.warning('%s: Update custom parallel updates: %s', self.name_model, num) + _LOGGER.debug('%s: Update custom parallel updates: %s', self.name_model, num) self.parallel_updates = pus return pus From a329f7d0aad1ded3effb45b8aae07cd802e8b0ec Mon Sep 17 00:00:00 2001 From: Alone Date: Sun, 7 Jul 2024 20:04:04 +0800 Subject: [PATCH 16/34] =?UTF-8?q?=E2=9A=A1=20add=20support=20for=20lxzn.sw?= =?UTF-8?q?itch.cbcsmj=20(#1727)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index fcdad3f4e..616dc2201 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -964,6 +964,12 @@ 'lumi.switch.*': { 'cloud_delay_update': 10, }, + 'lxzn.switch.cbcsmj': { + 'sensor_properties': 'temperature,electric_power', + 'select_properties': 'default_power_on_state', + 'switch_properties': 'electric_alarm_set,heat_alert_set,overcurrent_set,overvoltage_set,undervoltage_set', + 'number_properties': 'electric_alarm,heat_alert,overcurrent_alarm,overvoltage_alarm,undervoltage_alarm', + }, 'madv.cateye.mi3iot': { 'binary_sensor_properties': 'madv_doorbell.motion_detection', From ba43b58eaeeb54b3fef0d2d222469aa983c7ea21 Mon Sep 17 00:00:00 2001 From: Sean Yu <67294619+seanyu0@users.noreply.github.com> Date: Wed, 10 Jul 2024 14:35:38 +0800 Subject: [PATCH 17/34] =?UTF-8?q?=F0=9F=8C=90=20add=20dishwasher=20transla?= =?UTF-8?q?tion=20(#1755)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/translation_languages.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/custom_components/xiaomi_miot/core/translation_languages.py b/custom_components/xiaomi_miot/core/translation_languages.py index e8e903527..879200ca5 100644 --- a/custom_components/xiaomi_miot/core/translation_languages.py +++ b/custom_components/xiaomi_miot/core/translation_languages.py @@ -339,6 +339,32 @@ 'timed': '定时烘干', }, + 'dishwasher': { + 'dishwasher status': '状态', + 'dishwasher switch status': '开关', + 'dishwasher mode': '洗涤模式', + 'Start Wash': '开始洗涤', + 'Stop Washing': '停止洗涤', + 'dishwasher left time': '洗涤剩余时间', + }, + 'dishwasher.mode': { + 'Basic': '标准洗', + 'Energy Saving': '节能洗', + 'Quick Wash': '快速洗', + 'Intensive': '强力洗', + 'Glass': '玻璃洗', + 'Disinfecting': '消毒洗', + }, + 'dishwasher.status': { + 'Off': '已关机', + 'Idle': '已停止', + 'Busy': '工作中', + 'Paused': '暂停', + 'Completed': '洗涤完成', + 'Delay': '已预约', + 'Preservation': '保留', + }, + 'water_heater': { 'water heater': '热水器', }, From 9fca2bee1f9d9b3e5b0c837d1f8325024cc900d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Wed, 10 Jul 2024 14:44:58 +0800 Subject: [PATCH 18/34] =?UTF-8?q?=F0=9F=8E=B6=20fix=20play=20music=20for?= =?UTF-8?q?=20xiaoai=20(#1756)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/media_player.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/custom_components/xiaomi_miot/media_player.py b/custom_components/xiaomi_miot/media_player.py index 4766b7186..56e26d77c 100644 --- a/custom_components/xiaomi_miot/media_player.py +++ b/custom_components/xiaomi_miot/media_player.py @@ -509,6 +509,10 @@ def turn_off(self): async def async_play_media(self, media_type, media_id, **kwargs): if not self.xiaoai_device: return + hardware = self.xiaoai_device.get("hardware") + if hardware in [ "LX04", "L05B", "L05C", "L06", "L06A", "X08A", "X10A" ]: + return await self.async_play_music(media_id) + aid = self.xiaoai_device.get('deviceID') typ = { 'music': 1, @@ -526,6 +530,47 @@ async def async_play_media(self, media_type, media_id, **kwargs): logger = rdt.get('code') and self.logger.warning or self.logger.info logger('%s: Play media: %s', self.name_model, [dat, rdt]) + async def async_play_music(self, media_id, audio_id="1582971365183456177", id="355454500", **kwargs): + if not self.xiaoai_device: + return + aid = self.xiaoai_device.get('deviceID') + music = { + "payload": { + "audio_type": "MUSIC", + "audio_items": [ + { + "item_id": { + "audio_id": audio_id, + "cp": { + "album_id": "-1", + "episode_index": 0, + "id": id, + "name": "xiaowei", + }, + }, + "stream": {"url": media_id}, + } + ], + "list_params": { + "listId": "-1", + "loadmore_offset": 0, + "origin": "xiaowei", + "type": "MUSIC", + }, + }, + "play_behavior": "REPLACE_ALL", + } + api = 'https://api2.mina.mi.com/remote/ubus' + dat = { + 'deviceId': aid, + 'path': 'mediaplayer', + 'method': 'player_play_music', + 'message': json.dumps({"startaudioid": audio_id, "music": json.dumps(music)}), + } + rdt = await self.xiaoai_cloud.async_request_api(api, data=dat, method='POST') or {} + logger = rdt.get('code') and self.logger.warning or self.logger.info + logger('%s: Play Music: %s', self.name_model, [dat, rdt]) + def intelligent_speaker(self, text, execute=False, silent=False, **kwargs): if srv := self._intelligent_speaker: anm = 'execute_text_directive' if execute else 'play_text' From 75d978ffdaa9fa84982f01dbd8bd8a833cfb4f92 Mon Sep 17 00:00:00 2001 From: Alone Date: Wed, 10 Jul 2024 15:48:39 +0800 Subject: [PATCH 19/34] =?UTF-8?q?=F0=9F=8F=8B=EF=B8=8F=20add=20support=20f?= =?UTF-8?q?or=20pressure-sensor=20(#1532)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 4 ++++ custom_components/xiaomi_miot/sensor.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 616dc2201..f21dda7ce 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1919,6 +1919,10 @@ 'number_properties': 'target_temperature', 'switch_properties': 'oven.on', }, + '*.senpres.*': { + 'binary_sensor_properties': 'pressure_present_state', + 'sensor_properties': 'pressure_not_present_duration', + }, '*.s_lamp.*': { 'sensor_properties': 'left_time', 'switch_properties': 'uv,radar_on,lighting.on', diff --git a/custom_components/xiaomi_miot/sensor.py b/custom_components/xiaomi_miot/sensor.py index 12651ebd0..aff8d80fd 100644 --- a/custom_components/xiaomi_miot/sensor.py +++ b/custom_components/xiaomi_miot/sensor.py @@ -106,7 +106,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= if isinstance(spec, MiotSpec): for srv in spec.get_services( 'battery', 'environment', 'tds_sensor', 'switch_sensor', 'vibration_sensor', 'occupancy_sensor', - 'temperature_humidity_sensor', 'illumination_sensor', 'gas_sensor', 'smoke_sensor', + 'temperature_humidity_sensor', 'illumination_sensor', 'gas_sensor', 'smoke_sensor', 'pressure_sensor', 'router', 'lock', 'door', 'washer', 'printer', 'sleep_monitor', 'bed', 'walking_pad', 'treadmill', 'oven', 'microwave_oven', 'health_pot', 'coffee_machine', 'multifunction_cooking_pot', 'cooker', 'induction_cooker', 'pressure_cooker', 'air_fryer', 'juicer', 'electric_steamer', @@ -194,6 +194,8 @@ def __init__(self, config, miot_service: MiotService): self._prop_state = miot_service.get_property('smoke_concentration') or self._prop_state elif miot_service.name in ['occupancy_sensor']: self._prop_state = miot_service.get_property('occupancy_status') or self._prop_state + elif miot_service.name in ['pressure_sensor']: + self._prop_state = miot_service.get_property('pressure_present_duration') or self._prop_state self._attr_icon = self._miot_service.entity_icon self._attr_state_class = None From d1d5c0b1586444c34cfdda119cac4e337f11a5f2 Mon Sep 17 00:00:00 2001 From: Alone Date: Wed, 10 Jul 2024 15:57:45 +0800 Subject: [PATCH 20/34] =?UTF-8?q?=F0=9F=99=88=20hide=20default=20branch=20?= =?UTF-8?q?for=20hacs=20(#1751)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hacs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/hacs.json b/hacs.json index 7fc4c1b54..b7aeeddf7 100644 --- a/hacs.json +++ b/hacs.json @@ -4,5 +4,6 @@ "zip_release": true, "filename": "xiaomi_miot.zip", "render_readme": true, + "hide_default_branch": true, "homeassistant": "2023.1.0" } From 78d35afd00690c68222154689f109f4ba12a22b2 Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 11 Jul 2024 14:55:58 +0800 Subject: [PATCH 21/34] =?UTF-8?q?=F0=9F=93=B6=20update=20miot=20local=20de?= =?UTF-8?q?vices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/miot_local_devices.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/custom_components/xiaomi_miot/core/miot_local_devices.py b/custom_components/xiaomi_miot/core/miot_local_devices.py index 64c580f61..b475815a8 100644 --- a/custom_components/xiaomi_miot/core/miot_local_devices.py +++ b/custom_components/xiaomi_miot/core/miot_local_devices.py @@ -1,4 +1,5 @@ MIOT_LOCAL_MODELS = [ + # '090615.curtain.jldj03', # '090615.curtain.kcz82d', # -4004 # '090615.curtain.ptx82', # -4004 # '090615.curtain.sidt82', # -4004 @@ -329,6 +330,7 @@ 'leishi.light.eps112', 'leishi.light.eps118', 'leishi.light.eps121', + 'leishi.light.eps126', 'leishi.light.eps127', 'leishi.light.wy0a06', 'leishi.light.wy0a10', @@ -356,6 +358,7 @@ 'linp.switch.q33', 'linp.switch.s2dw3', 'lipro.light.23x1', + 'lipro.light.23x2', 'loock.camera.c1k', 'loock.cateye.v06', 'loock.cateye.v07', @@ -384,6 +387,7 @@ 'mibx2.washer.v11', 'mibx2.washer.v11rm', 'mibx2.washer.v13', + 'mibx2.washer.v17', 'mibx2.washer.v2', 'mibx2.washer.v3', 'mibx2.washer.v5', @@ -440,6 +444,7 @@ 'nineam.desk.hoo01', 'nnleaf.light.strips', 'noc196.light.mdyctd', + 'novo.airer.g30', 'novo.curtain.n21', 'nwt.derh.312en', 'nwt.derh.330ef', @@ -530,6 +535,7 @@ 'viomi.aircondition.y112', 'viomi.aircondition.y113', 'viomi.aircondition.y115', + 'viomi.aircondition.y117', 'viomi.aircondition.y15', 'viomi.aircondition.y64', 'viomi.aircondition.y69', @@ -544,12 +550,18 @@ 'viomi.airp.v3', 'viomi.bhf_light.v3', 'viomi.bhf_light.v4', + 'viomi.bhf_light.v6', 'viomi.dishwasher.m03', 'viomi.dishwasher.v06', 'viomi.dishwasher.v07', + 'viomi.dishwasher.v08', 'viomi.dishwasher.v09', 'viomi.dishwasher.v10', 'viomi.dishwasher.v11', + 'viomi.dishwasher.v12', + 'viomi.dishwasher.v14', + 'viomi.dishwasher.v15', + 'viomi.dishwasher.v17', 'viomi.dishwasher.v23', 'viomi.fan.v13', 'viomi.fan.v6', @@ -629,6 +641,7 @@ 'xiaomi.aircondition.c32', 'xiaomi.aircondition.c33', 'xiaomi.aircondition.c36', + 'xiaomi.aircondition.m11', 'xiaomi.aircondition.m16', 'xiaomi.aircondition.m19', 'xiaomi.aircondition.m3', @@ -698,6 +711,7 @@ 'xiaomi.vacuum.c101', 'xiaomi.vacuum.c101eu', 'xiaomi.vacuum.c102cn', + 'xiaomi.vacuum.c102gl', 'xiaomi.vacuum.c103', 'xiaomi.vacuum.c104', 'xiaomi.vacuum.c107', @@ -793,6 +807,7 @@ 'yunmi.waterpuri.s31', 'yunmi.waterpuri.x10', 'yunmi.ysj.v1', + 'yunmi.ysj.x2', 'yyunyi.wopener.yylt', 'yywq.toilet.wqzn01', 'zair.switch.zsc02w', @@ -815,6 +830,7 @@ 'zhimi.airp.sa4', 'zhimi.airp.ua1', 'zhimi.airp.ua1a', + 'zhimi.airp.ua2', 'zhimi.airp.va2', 'zhimi.airp.va2a', 'zhimi.airp.vb2a', From 136de069dac05a1935bf5880ec835b6aeec0b7ec Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 11 Jul 2024 15:04:18 +0800 Subject: [PATCH 22/34] =?UTF-8?q?=E2=AC=86=20new=20version=20v0.7.19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_miot/manifest.json b/custom_components/xiaomi_miot/manifest.json index 9a5400ae6..48c57a913 100644 --- a/custom_components/xiaomi_miot/manifest.json +++ b/custom_components/xiaomi_miot/manifest.json @@ -17,5 +17,5 @@ "python-miio>=0.5.12", "micloud>=0.5" ], - "version": "0.7.18" + "version": "0.7.19" } From 181522b8fe1e093df8d3bf88b13c4d99d5d8084a Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 11 Jul 2024 22:59:18 +0800 Subject: [PATCH 23/34] =?UTF-8?q?=F0=9F=94=A7=20add=20support=20for=20pyth?= =?UTF-8?q?on-miio=20v0.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/remote.py | 11 ++-- custom_components/xiaomi_miot/sensor.py | 76 ------------------------- 2 files changed, 6 insertions(+), 81 deletions(-) diff --git a/custom_components/xiaomi_miot/remote.py b/custom_components/xiaomi_miot/remote.py index 46dd46f00..fb509b97e 100644 --- a/custom_components/xiaomi_miot/remote.py +++ b/custom_components/xiaomi_miot/remote.py @@ -13,16 +13,12 @@ RemoteEntity, ) -from miio.chuangmi_ir import ( - ChuangmiIr, - DeviceException, -) - from . import ( DOMAIN, CONF_MODEL, XIAOMI_CONFIG_SCHEMA as PLATFORM_SCHEMA, # noqa: F401 MiotEntity, + DeviceException, async_setup_config_entry, bind_services_to_entries, ) @@ -35,6 +31,11 @@ MiCloudException, ) +try: + from miio import ChuangmiIr +except (ModuleNotFoundError, ImportError): + from miio.integrations.chuangmi.remote import ChuangmiIr + _LOGGER = logging.getLogger(__name__) DATA_KEY = f'{ENTITY_DOMAIN}.{DOMAIN}' diff --git a/custom_components/xiaomi_miot/sensor.py b/custom_components/xiaomi_miot/sensor.py index aff8d80fd..d1a18a8ce 100644 --- a/custom_components/xiaomi_miot/sensor.py +++ b/custom_components/xiaomi_miot/sensor.py @@ -25,7 +25,6 @@ ) from homeassistant.helpers.restore_state import RestoreEntity, RestoredExtraData from homeassistant.helpers.update_coordinator import DataUpdateCoordinator -from miio.waterpurifier_yunmi import WaterPurifierYunmi from . import ( DOMAIN, @@ -534,81 +533,6 @@ def native_value(self): return val -class WaterPurifierYunmiEntity(MiioEntity, Entity): - def __init__(self, config): - name = config[CONF_NAME] - host = config[CONF_HOST] - token = config[CONF_TOKEN] - _LOGGER.info('%s: Initializing with host %s (token %s...)', name, host, token[:5]) - - self._device = WaterPurifierYunmi(host, token) - super().__init__(name, self._device, config=config, logger=_LOGGER) - self._subs = { - 'tds_in': {'keys': ['tds_warn_thd'], 'unit': CONCENTRATION_PARTS_PER_MILLION, 'icon': 'mdi:water'}, - 'tds_out': {'keys': ['tds_warn_thd'], 'unit': CONCENTRATION_PARTS_PER_MILLION, 'icon': 'mdi:water-check'}, - 'temperature': {'class': SensorDeviceClass.TEMPERATURE, 'unit': UnitOfTemperature.CELSIUS}, - } - for i in [1, 2, 3]: - self._subs.update({ - f'f{i}_remaining': { - 'keys': [f'f{i}_totalflow', f'f{i}_usedflow'], - 'unit': PERCENTAGE, - 'icon': 'mdi:water-percent', - }, - f'f{i}_remain_days': { - 'keys': [f'f{i}_totaltime', f'f{i}_usedtime'], - 'unit': UnitOfTime.DAYS, - 'icon': 'mdi:clock', - }, - }) - - @property - def state(self): - return self._state - - @property - def icon(self): - return 'mdi:water-pump' - - @property - def unit_of_measurement(self): - return CONCENTRATION_PARTS_PER_MILLION - - async def async_update(self): - try: - status = await self.hass.async_add_executor_job(partial(self._device.status)) - except DeviceException as ex: - if self._available: - self._available = False - _LOGGER.error('Got exception while fetching the state for %s: %s', self.entity_id, ex) - return - attrs = status.data or {} - _LOGGER.debug('Got new state from %s: %s', self.entity_id, attrs) - self._available = True - self._state = int(attrs.get('tds_out', 0)) - self._state_attrs.update(attrs) - for i in [1, 2, 3]: - self._state_attrs.update({ - f'f{i}_remaining': round(100 - 100 * attrs[f'f{i}_usedtime'] / attrs[f'f{i}_totaltime']), - f'f{i}_remain_days': round((attrs[f'f{i}_totaltime'] - attrs[f'f{i}_usedtime']) / 24), - }) - self._state_attrs.update({ - 'errors': '|'.join(status.operation_status.errors), - }) - add_entities = self._add_entities.get('sensor') - for k, v in self._subs.items(): - if 'entity' in v: - v['entity'].update_from_parent() - elif add_entities: - v['entity'] = WaterPurifierYunmiSubEntity(self, k, v) - add_entities([v['entity']], update_before_add=True) - - -class WaterPurifierYunmiSubEntity(BaseSubEntity): - def __init__(self, parent: WaterPurifierYunmiEntity, attr, option=None): - super().__init__(parent, attr, option) - - class MihomeMessageSensor(MiCoordinatorEntity, SensorEntity, RestoreEntity): _filter_homes = None _exclude_types = None From c2e9eed879472fb6be3c970301311d61946867d0 Mon Sep 17 00:00:00 2001 From: Alone Date: Sat, 13 Jul 2024 20:25:42 +0800 Subject: [PATCH 24/34] =?UTF-8?q?=F0=9F=8E=B6=20improve=20play=20music=20f?= =?UTF-8?q?or=20xiaoai?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/media_player.py | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/custom_components/xiaomi_miot/media_player.py b/custom_components/xiaomi_miot/media_player.py index 56e26d77c..863169a33 100644 --- a/custom_components/xiaomi_miot/media_player.py +++ b/custom_components/xiaomi_miot/media_player.py @@ -342,6 +342,12 @@ def __init__(self, config: dict, miot_service: MiotService): self._state_attrs[ATTR_ATTRIBUTION] = 'Support TTS through service' self._supported_features |= MediaPlayerEntityFeature.PLAY_MEDIA + @property + def xiaoai_id(self): + if not self.xiaoai_device: + return None + return self.xiaoai_device.get('deviceID') + async def async_added_to_hass(self): await super().async_added_to_hass() if self._intelligent_speaker: @@ -393,12 +399,9 @@ async def async_update_xiaoai_device(self): return self.xiaoai_device async def async_update_play_status(self, now=None): - if not self.xiaoai_device: + if not (aid := self.xiaoai_id): return - aid = self.xiaoai_device.get('deviceID') - self.update_attrs({ - 'xiaoai_id': aid, - }) + self.update_attrs({'xiaoai_id': aid}) api = 'https://api2.mina.mi.com/remote/ubus' dat = { 'deviceId': aid, @@ -507,18 +510,18 @@ def turn_off(self): return False async def async_play_media(self, media_type, media_id, **kwargs): - if not self.xiaoai_device: + if not (aid := self.xiaoai_id): return - hardware = self.xiaoai_device.get("hardware") - if hardware in [ "LX04", "L05B", "L05C", "L06", "L06A", "X08A", "X10A" ]: - return await self.async_play_music(media_id) - - aid = self.xiaoai_device.get('deviceID') typ = { + 'audio': 1, 'music': 1, 'voice': 1, + 'mp3': 1, 'tts': 1, }.get(media_type, media_type) + if typ == 1: + return await self.async_play_music(media_id) + api = 'https://api2.mina.mi.com/remote/ubus' dat = { 'deviceId': aid, @@ -531,9 +534,8 @@ async def async_play_media(self, media_type, media_id, **kwargs): logger('%s: Play media: %s', self.name_model, [dat, rdt]) async def async_play_music(self, media_id, audio_id="1582971365183456177", id="355454500", **kwargs): - if not self.xiaoai_device: + if not (aid := self.xiaoai_id): return - aid = self.xiaoai_device.get('deviceID') music = { "payload": { "audio_type": "MUSIC", From 38e2a2627477a9ecf40e34b0f221367537299f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=92=B8=E9=B1=BC=E8=80=8C=E5=B7=B2?= <64669899+hvvvvvvv@users.noreply.github.com> Date: Sun, 14 Jul 2024 13:35:05 +0800 Subject: [PATCH 25/34] =?UTF-8?q?=F0=9F=94=A7=20fix=20option=20`interval?= =?UTF-8?q?=5Fseconds`=20(#1763)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 08ddcf0fc..1964812e9 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -841,6 +841,8 @@ def update_custom_scan_interval(self, only_custom=False): tim = timedelta(seconds=sec) if sec > 0 and tim != self.platform.scan_interval: self.platform.scan_interval = tim + if hasattr(self.platform, 'scan_interval_seconds'): + self.platform.scan_interval_seconds = tim.total_seconds() _LOGGER.debug('%s: Update custom scan interval: %s', self.name_model, tim) def update_custom_parallel_updates(self): From 9c97aa7296ab07707165b9d3f35b31b1ca8a7d60 Mon Sep 17 00:00:00 2001 From: almirus Date: Sun, 14 Jul 2024 08:36:34 +0300 Subject: [PATCH 26/34] =?UTF-8?q?=F0=9F=8C=90=20fix=20typos=20for=20ru=20(?= =?UTF-8?q?#1759)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/translations/ru.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/xiaomi_miot/translations/ru.json b/custom_components/xiaomi_miot/translations/ru.json index a2ecd1dd6..490450a77 100644 --- a/custom_components/xiaomi_miot/translations/ru.json +++ b/custom_components/xiaomi_miot/translations/ru.json @@ -44,7 +44,7 @@ } }, "customizing": { - "title": "Изменение сущьностей / устройств", + "title": "Изменение сущностей / устройств", "description": "{tip}", "data": { "domain": "Выберите домен сущности", @@ -58,8 +58,8 @@ } }, "error": { - "cannot_connect": "Не удалость подключиться к устройству", - "cannot_login": "Не удалось полключиться к аккаунту Сяоми. Проверьте пароль. При повторных ошибках авторизируйтесь на mi.com в той же среде и попробуйте снова.", + "cannot_connect": "Не удалось подключиться к устройству", + "cannot_login": "Не удалось подключиться к аккаунту Сяоми. Проверьте пароль. При повторных ошибках авторизируйтесь на mi.com в той же среде и попробуйте снова.", "cannot_reach": "Нет доступа к API Сяоми", "tzinfo_error": "Перейдите по ссылке: https://github.com/al-one/hass-xiaomi-miot/issues/260", "none_devices": "Не найдено устройств в облаке Сяоми" @@ -126,7 +126,7 @@ "can_reach_server": "Доступность API сервера Сяоми", "can_reach_spec": "Доступность MIoT-Spec сервера", "logged_accounts": "Авторизованные аккаунты", - "total_devices": "Общее количесво устройств MiHome" + "total_devices": "Общее количество устройств MiHome" } } } From 390a4867853d0a735e73545833d995dc317138d6 Mon Sep 17 00:00:00 2001 From: whc2001 Date: Sun, 14 Jul 2024 01:38:06 -0400 Subject: [PATCH 27/34] =?UTF-8?q?=F0=9F=92=A6=20improve=20for=20humidifier?= =?UTF-8?q?=20(#1761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔧 fix humidifier mode setting when power is off * 🔧 allow mode sanity check before turning on --- custom_components/xiaomi_miot/humidifier.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/xiaomi_miot/humidifier.py b/custom_components/xiaomi_miot/humidifier.py index ebd112edf..d09b1456c 100644 --- a/custom_components/xiaomi_miot/humidifier.py +++ b/custom_components/xiaomi_miot/humidifier.py @@ -195,4 +195,7 @@ def set_mode(self, mode: str): val = self._prop_mode.list_value(mode) if val is None: return False + if mode != MODE_OFF and not self.is_on: + if not self.turn_on(): + return False return self.set_property(self._prop_mode, val) From 322ceb910c51671a133115c71d3756b0db22d0f8 Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 18 Jul 2024 15:47:16 +0800 Subject: [PATCH 28/34] =?UTF-8?q?=F0=9F=9A=B6=20improve=20for=20occupy=20s?= =?UTF-8?q?ensor=20(#1700)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index f21dda7ce..71bc2cf74 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1914,6 +1914,9 @@ '*.motion.*:trigger_at': { 'device_class': 'timestamp', }, + '*.sensor_occupy.*': { + 'sensor_properties': 'illumination,has_someone_duration,no_one_duration', + }, '*.oven.*': { 'sensor_properties': 'temperature,left_time,cook_time,working_time', 'number_properties': 'target_temperature', From 966fbbeef7f614809a75eba825b636ef9124cd70 Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 18 Jul 2024 15:55:01 +0800 Subject: [PATCH 29/34] =?UTF-8?q?=F0=9F=9A=BD=20improve=20for=20xjx.toilet?= =?UTF-8?q?.relaxp=20(#1762)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/__init__.py | 2 +- custom_components/xiaomi_miot/core/device_customizes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/xiaomi_miot/__init__.py b/custom_components/xiaomi_miot/__init__.py index 1964812e9..30bbb1554 100644 --- a/custom_components/xiaomi_miot/__init__.py +++ b/custom_components/xiaomi_miot/__init__.py @@ -2102,7 +2102,7 @@ def _update_sub_entities(self, properties, services=None, domain=None, option=No fnm = f elif p.full_name not in self._state_attrs and not p.writeable and not kwargs.get('whatever'): continue - elif add_switches and domain == 'switch' and (p.format in ['bool'] or p.value_list) and p.writeable: + elif add_switches and domain == 'switch' and (p.format in ['bool', 'uint8']) and p.writeable: self._subs[fnm] = MiotSwitchSubEntity(self, p, option=opt) add_switches([self._subs[fnm]], update_before_add=True) elif add_binary_sensors and domain == 'binary_sensor' and (p.is_bool or p.is_integer): diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 71bc2cf74..a8dbec046 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1499,7 +1499,7 @@ 'switch_properties': 'status_seatheat,status_led,auto_led,switch_bubble,status_seat,status_cover,' 'auto_seat_close,auto_cover_close,status_selfclean', 'select_properties': 'seat_temp', - 'button_actions': 'stop_working', + 'button_actions': 'stop_working,flush_work,start_foam,clean_work', }, 'xwhzp.diffuser.xwxfj': { 'sensor_properties': 'fragrance_liquid_left_level', From 09b359d640ede5030b612f46717bfee578b0fd01 Mon Sep 17 00:00:00 2001 From: Alone Date: Thu, 18 Jul 2024 15:59:50 +0800 Subject: [PATCH 30/34] =?UTF-8?q?=F0=9F=91=95=20improve=20for=20hyd.airer?= =?UTF-8?q?=20(#1762)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/core/device_customizes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index a8dbec046..68ddb2ada 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -665,6 +665,7 @@ 'switch_properties': 'alarm_shielding,silent_mode,line_exchange', }, 'hyd.airer.lyjpro': { + 'position_reverse': True, 'cover_position_mapping': {}, }, 'hyd.airer.*': { @@ -674,6 +675,7 @@ 'number_properties': 'drying_time', 'exclude_miot_properties': 'motor_control', 'disable_target_position': True, + 'position_reverse': False, 'cover_position_mapping': { 0: 50, 1: 100, From 8d7dae5975e8ef161695a7b440a01ffcc831b9f8 Mon Sep 17 00:00:00 2001 From: Alone Date: Fri, 19 Jul 2024 11:00:31 +0800 Subject: [PATCH 31/34] =?UTF-8?q?=F0=9F=90=88=20improve=20for=20mmgg.feede?= =?UTF-8?q?r=20(#1580)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/device_customizes.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 68ddb2ada..86a0f25f9 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -1006,10 +1006,22 @@ 'mmgg.feeder.fi1': { 'chunk_properties': 1, 'state_property': 'pet_food_left_level', - 'button_actions': 'reset_desiccant_life,resetclean,pet_food_out', - 'sensor_properties': 'desiccant_left_time,cleantime,fault,outletstatus,doorstatus', + 'button_actions': 'pet_food_out,resetclean,reset_desiccant_life', + 'binary_sensor_properties': 'outletstatus,doorstatus', + 'sensor_properties': 'fault,outfood_num,cleantime,desiccant_left_time', 'number_properties': 'key_stat,indicator_light.on', - 'exclude_miot_properties': 'outfood_num,outfood_id,contrycode,feddplan_string,factory_result', + 'exclude_miot_properties': 'outfood_id,contrycode,feddplan_string,factory_result,phon_time_zone' + 'feedplan_hour,feedplan_min,feedplan_unit,feedplan_stat,feedplan_id,getfeedplan_num', + }, + 'mmgg.feeder.inland': { + 'chunk_properties': 1, + 'state_property': 'pet_food_left_level', + 'button_actions': 'pet_food_out,resetclean,reset_desiccant_life', + 'binary_sensor_properties': 'outletstatus,doorstatus', + 'sensor_properties': 'outfood_num,foodstatus,desiccant_left_time,cleantime', + 'switch_properties': 'key_stat,indicator_light.on', + 'exclude_miot_properties': 'fault,outfood_id,contrycode,feddplan_string,factory_result,phon_time_zone,' + 'feedplan_hour,feedplan_min,feedplan_unit,feedplan_stat,feedplan_id,getfeedplan_num', }, 'mmgg.feeder.petfeeder': { 'state_property': 'pet_food_left_level', From c1a6c6ebb592a4ce3ee1f21d820f54106a3f6303 Mon Sep 17 00:00:00 2001 From: SodaWithoutSparkles <64138578+SodaWithoutSparkles@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:05:59 +0800 Subject: [PATCH 32/34] =?UTF-8?q?=E2=81=89=EF=B8=8F=20update=20issue=20tem?= =?UTF-8?q?plates=20(#1776)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/device-issue.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/device-issue.yml b/.github/ISSUE_TEMPLATE/device-issue.yml index b290c0e95..80420c598 100644 --- a/.github/ISSUE_TEMPLATE/device-issue.yml +++ b/.github/ISSUE_TEMPLATE/device-issue.yml @@ -22,7 +22,7 @@ body: - type: input attributes: label: HA core version / HA版本 - placeholder: 2022.12.x + placeholder: 2024.x.x description: | > [⚙️ Settings > ℹ️️ About](https://my.home-assistant.io/redirect/info) > [⚙️ 配置 > ℹ️️ 关于](https://my.home-assistant.io/redirect/info) @@ -47,6 +47,7 @@ body: required: true attributes: label: Entity attributes / 实体属性 + render: yaml description: | > [🔨 Developer tools > ℹ️ State](https://my.home-assistant.io/redirect/developer_states) > 🔍 Filter (Entity with most attributes) > [🔨 开发者工具 > ℹ️ 状态](https://my.home-assistant.io/redirect/developer_states) > 🔍 筛选 (属性最多的实体) From 2f0b466ce9b5f0fb64054fbbfbb24ffd1c95c3c4 Mon Sep 17 00:00:00 2001 From: ljjnihao <469227155@qq.com> Date: Fri, 2 Aug 2024 14:07:32 +0800 Subject: [PATCH 33/34] =?UTF-8?q?=F0=9F=94=8B=20add=20energy=20for=20cuco.?= =?UTF-8?q?acpartner.cp6=20(#1784)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi_miot/core/device_customizes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 86a0f25f9..ec3f41ff1 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -224,6 +224,20 @@ }, 'cuco.acpartner.cp6': { 'switch_properties': 'air_conditioner.on', + 'sensor_attributes': 'power_cost_today,power_cost_month', + 'stat_power_cost_key': '7.1', + }, + 'cuco.acpartner.cp6:power_cost_today': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', + }, + 'cuco.acpartner.cp6:power_cost_month': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', }, 'cuco.light.sl4': { 'switch_properties': 'swich', From df9a4761ef172468d0ab223dd152977af4a60597 Mon Sep 17 00:00:00 2001 From: Oleg Karasik Date: Fri, 2 Aug 2024 09:09:49 +0300 Subject: [PATCH 34/34] =?UTF-8?q?=F0=9F=A7=B9=20improve=20for=20vacuum=20(?= =?UTF-8?q?#1791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/xiaomi_miot/vacuum.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/xiaomi_miot/vacuum.py b/custom_components/xiaomi_miot/vacuum.py index 3f3a81699..042dc63bd 100644 --- a/custom_components/xiaomi_miot/vacuum.py +++ b/custom_components/xiaomi_miot/vacuum.py @@ -141,9 +141,9 @@ def state(self): if val is None: pass elif val in self._prop_status.list_search( - 'Cleaning', 'Sweeping', 'Mopping', 'Sweeping and Mopping', + 'Cleaning', 'Sweeping', 'Mopping', 'Sweeping And Mopping', 'Washing', 'Go Washing', 'Part Sweeping', 'Zone Sweeping', 'Select Sweeping', 'Spot Sweeping', 'Goto Target', - 'Starting', 'Working', 'Busy', + 'Starting', 'Working', 'Busy', 'DustCollecting' ): return STATE_CLEANING elif val in self._prop_status.list_search('Idle', 'Sleep'):