From bff5b3bf4455de3260642dded4655a41fa19d093 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Tue, 17 Dec 2024 16:31:08 +0800 Subject: [PATCH 1/5] fix: air-conditioner switch on --- custom_components/xiaomi_home/climate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/custom_components/xiaomi_home/climate.py b/custom_components/xiaomi_home/climate.py index 860afac..baedf61 100644 --- a/custom_components/xiaomi_home/climate.py +++ b/custom_components/xiaomi_home/climate.py @@ -254,6 +254,7 @@ async def async_turn_off(self) -> None: async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" + # set air-conditioner off if hvac_mode == HVACMode.OFF and self._prop_on: if not await self.set_property_async( prop=self._prop_on, value=False): @@ -261,6 +262,11 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: f'set climate prop.on failed, {hvac_mode}, ' f'{self.entity_id}') return + # set air-conditioner on + if hvac_mode != HVACMode.OFF and not self.get_prop_value( + prop=self._prop_on): + await self.async_turn_on() + # set mode mode_value = self.get_map_value( map_=self._hvac_mode_map, description=hvac_mode) if ( From dbf943386ef5f2ec643c1d404b85deafd4e7650c Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Tue, 17 Dec 2024 17:33:28 +0800 Subject: [PATCH 2/5] fix: set prop --- custom_components/xiaomi_home/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/climate.py b/custom_components/xiaomi_home/climate.py index baedf61..0b1ffd7 100644 --- a/custom_components/xiaomi_home/climate.py +++ b/custom_components/xiaomi_home/climate.py @@ -265,7 +265,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: # set air-conditioner on if hvac_mode != HVACMode.OFF and not self.get_prop_value( prop=self._prop_on): - await self.async_turn_on() + await self.set_property_async(prop=self._prop_on, value=True) # set mode mode_value = self.get_map_value( map_=self._hvac_mode_map, description=hvac_mode) From da58d4c0a59aa52e8ff52cc334b9b4f3d1a0c8e5 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Tue, 17 Dec 2024 17:50:08 +0800 Subject: [PATCH 3/5] perf: remove permanent true statement --- custom_components/xiaomi_home/climate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_home/climate.py b/custom_components/xiaomi_home/climate.py index 0b1ffd7..a1d2ad4 100644 --- a/custom_components/xiaomi_home/climate.py +++ b/custom_components/xiaomi_home/climate.py @@ -255,7 +255,7 @@ async def async_turn_off(self) -> None: async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" # set air-conditioner off - if hvac_mode == HVACMode.OFF and self._prop_on: + if hvac_mode == HVACMode.OFF: if not await self.set_property_async( prop=self._prop_on, value=False): raise RuntimeError( @@ -263,7 +263,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: f'{self.entity_id}') return # set air-conditioner on - if hvac_mode != HVACMode.OFF and not self.get_prop_value( + elif not self.get_prop_value( prop=self._prop_on): await self.set_property_async(prop=self._prop_on, value=True) # set mode @@ -372,7 +372,7 @@ def current_humidity(self) -> Optional[int]: @ property def hvac_mode(self) -> Optional[HVACMode]: """Return the hvac mode. e.g., heat, cool mode.""" - if self._prop_on and self.get_prop_value(prop=self._prop_on) is False: + if not self.get_prop_value(prop=self._prop_on): return HVACMode.OFF return self.get_map_description( map_=self._hvac_mode_map, From b7fc534a34e518a3f05ee1a0049342b21335cfb6 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Tue, 17 Dec 2024 17:57:02 +0800 Subject: [PATCH 4/5] fix: bool value false --- custom_components/xiaomi_home/climate.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_home/climate.py b/custom_components/xiaomi_home/climate.py index a1d2ad4..cc12373 100644 --- a/custom_components/xiaomi_home/climate.py +++ b/custom_components/xiaomi_home/climate.py @@ -263,8 +263,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: f'{self.entity_id}') return # set air-conditioner on - elif not self.get_prop_value( - prop=self._prop_on): + elif self.get_prop_value(prop=self._prop_on) is False: await self.set_property_async(prop=self._prop_on, value=True) # set mode mode_value = self.get_map_value( @@ -372,7 +371,7 @@ def current_humidity(self) -> Optional[int]: @ property def hvac_mode(self) -> Optional[HVACMode]: """Return the hvac mode. e.g., heat, cool mode.""" - if not self.get_prop_value(prop=self._prop_on): + if self.get_prop_value(prop=self._prop_on) is False: return HVACMode.OFF return self.get_map_description( map_=self._hvac_mode_map, From be627afe54ce6c680e5bec4500a247c05198936f Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Wed, 18 Dec 2024 21:34:04 +0800 Subject: [PATCH 5/5] docs: add i18n in README --- README.md | 2 +- doc/README_zh.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c140586..fe3b75c 100644 --- a/README.md +++ b/README.md @@ -323,7 +323,7 @@ Device information service (urn:miot-spec-v2:service:device-information:00007801 ## Multiple Language Support -There are 8 languages available for selection in the config flow language option of Xiaomi Home, including Simplified Chinese, Traditional Chinese, English, Spanish, Russian, French, German, and Japanese. The config flow page in Simplified Chinese and English has been manually reviewed by the developer. Other languages are translated by machine translation. If you want to modify the words and sentences in the config flow page, you need to modify the json file of the certain language in `custom_components/xiaomi_home/translations/` directory. +There are 8 languages available for selection in the config flow language option of Xiaomi Home, including Simplified Chinese, Traditional Chinese, English, Spanish, Russian, French, German, and Japanese. The config flow page in Simplified Chinese and English has been manually reviewed by the developer. Other languages are translated by machine translation. If you want to modify the words and sentences in the config flow page, you need to modify the json file of the certain language in `custom_components/xiaomi_home/translations/` and `custom_components/xiaomi_home/miot/i18n/` directory. When displaying Home Assistant entity name, Xiaomi Home downloads the multiple language file configured by the device vendor from MIoT Cloud, which contains translations for MIoT-Spec-V2 instances of the device. `multi_lang.json` is a locally maintained multiple language dictionary, which has a higher priority than the multiple language file obtained from the cloud and can be used to supplement or modify the multiple language translation of devices. diff --git a/doc/README_zh.md b/doc/README_zh.md index cee5c67..742c0ea 100644 --- a/doc/README_zh.md +++ b/doc/README_zh.md @@ -325,7 +325,7 @@ event instance name 下的值表示转换后实体所用的 `_attr_device_class` ## 多语言支持 -米家集成配置选项中可选择的集成使用的语言有简体中文、繁体中文、英文、西班牙语、俄语、法语、德语、日语这八种语言。目前,米家集成配置页面的简体中文和英文已经过人工校审,其他语言由机器翻译。如果您希望修改配置页面的词句,则需要修改 `custom_components/xiaomi_home/translations/` 目录下相应语言的 json 文件。 +米家集成配置选项中可选择的集成使用的语言有简体中文、繁体中文、英文、西班牙语、俄语、法语、德语、日语这八种语言。目前,米家集成配置页面的简体中文和英文已经过人工校审,其他语言由机器翻译。如果您希望修改配置页面的词句,则需要修改 `custom_components/xiaomi_home/translations/` 以及 `custom_components/xiaomi_home/miot/i18n/` 目录下相应语言的 json 文件。 在显示 Home Assistant 实体名称时,米家集成会从小米云下载设备厂商为设备配置的多语言文件,该文件包含设备 MIoT-Spec-V2 实例的多语言翻译。 `multi_lang.json` 是本地维护的多语言配置字典,其优先级高于从云端获取的多语言文件,可用于补充或修改设备的多语言翻译。