Compare commits

...

5 Commits

Author SHA1 Message Date
Necroneco
3b41d26b2d
Merge 506bd9f52e into 7abc20dcb5 2025-11-11 15:01:02 +08:00
Li Shuzhen
7abc20dcb5
docs: update changelog and version to v0.4.4 (#1497)
Some checks failed
Tests / check-rule-format (push) Has been cancelled
Validate / validate-hassfest (push) Has been cancelled
Validate / validate-hacs (push) Has been cancelled
Validate / validate-lint (push) Has been cancelled
Validate / validate-setup (push) Has been cancelled
2025-11-11 09:12:55 +08:00
Li Shuzhen
3e33804477
Fix specs (#1496)
* fix: roidmi.vacuum.v60 duplicated service name for vacuum entity

* fix: cykj.hood.jyj22 spec urn version 4 (#1477)

* fix: lumi.motion.bmgl01 siid=2 piid=2 value-list (#1444)

* fix: ykcn.valve.cbcs power property value unit (#1488)

* fix: ainice.sensor_occupy.3b siid=2 piid=5,11,14,17 device_class (#1495)

* fix: qdhkl.airc.a42 hvac mode (#1483)
2025-11-11 08:56:33 +08:00
caibinqing
506bd9f52e
fix pylint 2025-04-07 11:19:19 +08:00
caibinqing
7c0caa9df7
fix: add migration step for config entry 2025-04-07 10:54:09 +08:00
9 changed files with 245 additions and 10 deletions

View File

@ -1,4 +1,13 @@
# CHANGELOG
## v0.4.4
### Added
- Add Turkish language support. [#1468](https://github.com/XiaoMi/ha_xiaomi_home/pull/1468)
### Fixed
- Stop MQTT internal loop immediately when main loop is closed. [#1465](https://github.com/XiaoMi/ha_xiaomi_home/pull/1465)
- Fix the float value precision. [#1485](https://github.com/XiaoMi/ha_xiaomi_home/pull/1485)
- Fix the climate entity swing mode setting. [#1486](https://github.com/XiaoMi/ha_xiaomi_home/pull/1486)
- Fix the MIoT-Spec-V2 of cykj.hood.jyj22 urn version 4, lumi.motion.bmgl01 siid=2 piid=2 value-list, ykcn.valve.cbcs power property value unit, ainice.sensor_occupy.3b people-number property and qdhkl.airc.a42 hvac mode. [#1496](https://github.com/XiaoMi/ha_xiaomi_home/pull/1496)
## v0.4.3
### Changed
- Remove `VacuumEntityFeature.BATTERY` from the vacuum entity. [#1433](https://github.com/XiaoMi/ha_xiaomi_home/pull/1433)

View File

@ -349,3 +349,101 @@ async def async_remove_config_entry_device(
_LOGGER.info(
'remove device, %s, %s', identifiers[1], device_entry.id)
return True
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry):
"""Migrate old entry."""
_LOGGER.debug(
'Migrating configuration from version %s.%s',
config_entry.version,
config_entry.minor_version,
)
if config_entry.version > 1:
# This means the user has downgraded from a future version
return False
if config_entry.version == 1:
await _migrate_v1_to_v2(hass, config_entry)
_LOGGER.debug(
'Migration to configuration version %s.%s successful',
config_entry.version,
config_entry.minor_version,
)
return True
async def _migrate_v1_to_v2(hass: HomeAssistant, config_entry: ConfigEntry):
def ha_persistent_notify(
notify_id: str, title: Optional[str] = None,
message: Optional[str] = None
) -> None:
"""Send messages in Notifications dialog box."""
if title:
persistent_notification.async_create(
hass=hass, message=message or '',
title=title, notification_id=notify_id)
else:
persistent_notification.async_dismiss(
hass=hass, notification_id=notify_id)
entry_id = config_entry.entry_id
entry_data = dict(config_entry.data)
ha_persistent_notify(
notify_id=f'{entry_id}.oauth_error', title=None, message=None)
miot_client: MIoTClient = await get_miot_instance_async(
hass=hass, entry_id=entry_id,
entry_data=entry_data,
persistent_notify=ha_persistent_notify)
# Spec parser
spec_parser = MIoTSpecParser(
lang=entry_data.get(
'integration_language', DEFAULT_INTEGRATION_LANGUAGE),
storage=miot_client.miot_storage,
loop=miot_client.main_loop
)
await spec_parser.init_async()
# Manufacturer
manufacturer: DeviceManufacturer = DeviceManufacturer(
storage=miot_client.miot_storage,
loop=miot_client.main_loop)
await manufacturer.init_async()
er = entity_registry.async_get(hass)
for _, info in miot_client.device_list.items():
spec_instance = await spec_parser.parse(urn=info['urn'])
if not isinstance(spec_instance, MIoTSpecInstance):
continue
device: MIoTDevice = MIoTDevice(
miot_client=miot_client,
device_info={
**info, 'manufacturer': manufacturer.get_name(
info.get('manufacturer', ''))},
spec_instance=spec_instance)
device.spec_transform()
# Update unique_id
for platform, entities in device.entity_list.items():
for entity in entities:
if not isinstance(entity.spec, MIoTSpecService):
continue
old_unique_id = device.gen_service_entity_id_v1(
ha_domain=DOMAIN,
siid=entity.spec.iid,
)
entity_id = er.async_get_entity_id(
platform, DOMAIN, old_unique_id
)
if entity_id is None:
continue
new_unique_id = device.gen_service_entity_id(
ha_domain=DOMAIN,
siid=entity.spec.iid,
description=entity.spec.description,
)
er.async_update_entity(entity_id, new_unique_id=new_unique_id)
hass.config_entries.async_update_entry(config_entry, version=2)

View File

@ -529,6 +529,8 @@ class AirConditioner(FeatureOnOff, FeatureTargetTemperature,
self._hvac_mode_map[item.value] = HVACMode.DRY
elif item.name in {'fan'}:
self._hvac_mode_map[item.value] = HVACMode.FAN_ONLY
elif item.name in {'heat_cool'}:
self._hvac_mode_map[item.value] = HVACMode.HEAT_COOL
self._attr_hvac_modes = list(self._hvac_mode_map.values())
self._prop_mode = prop
elif prop.name == 'ac-state':

View File

@ -108,7 +108,7 @@ _LOGGER = logging.getLogger(__name__)
class XiaomiMihomeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Xiaomi Home config flow."""
# pylint: disable=unused-argument, inconsistent-quotes
VERSION = 1
VERSION = 2
MINOR_VERSION = 1
DEFAULT_AREA_NAME_RULE = 'room'
_main_loop: asyncio.AbstractEventLoop

View File

@ -25,7 +25,7 @@
"cryptography",
"psutil"
],
"version": "v0.4.3",
"version": "v0.4.4",
"zeroconf": [
"_miot-central._tcp.local."
]

View File

@ -345,6 +345,11 @@ class MIoTDevice:
f'{ha_domain}.{self._model_strs[0][:9]}_{self.did_tag}_'
f'{self._model_strs[-1][:20]}')
def gen_service_entity_id_v1(self, ha_domain: str, siid: int) -> str:
return (
f'{ha_domain}.{self._model_strs[0][:9]}_{self.did_tag}_'
f'{self._model_strs[-1][:20]}_s_{siid}')
def gen_service_entity_id(self, ha_domain: str, siid: int,
description: str) -> str:
return (
@ -747,6 +752,7 @@ class MIoTDevice:
'watt': UnitOfPower.WATT,
'w': UnitOfPower.WATT,
'W': UnitOfPower.WATT,
'kW': UnitOfPower.KILO_WATT,
'kWh': UnitOfEnergy.KILO_WATT_HOUR,
'A': UnitOfElectricCurrent.AMPERE,
'mA': UnitOfElectricCurrent.MILLIAMPERE,

View File

@ -5,6 +5,12 @@
"service:003:property:001:valuelist:001": "Dry"
}
},
"urn:miot-spec-v2:device:electronic-valve:0000A0A7:ykcn-cbcs": {
"zh-Hans": {
"service:004:property:001": "功率过高-阈值设置",
"service:004:property:009": "欠压告警-阈值设置"
}
},
"urn:miot-spec-v2:device:fan:0000A005:zhimi-za1": {
"zh-Hans": {
"service:002:property:005:valuelist:000": "自然风",

View File

@ -1679,7 +1679,7 @@
"urn:miot-spec-v2:device:vacuum:0000A006:roidmi-v60:3": [
{
"iid": 2,
"type": "urn:miot-spec-v2:service:vacuum:00007810:roidmi-v60:1",
"type": "urn:miot-spec-v2:service:cleaner:00007810:roidmi-v60:1",
"description": "Robot Cleaner",
"actions": [
{

View File

@ -1,6 +1,21 @@
urn:miot-spec-v2:device:air-condition-outlet:0000A045:lumi-mcn04:1:
prop.3.4:
format: uint8
urn:miot-spec-v2:device:air-conditioner:0000A004:qdhkl-a42:1:
prop.2.2:
value-list:
- value: 1
description: Cool
- value: 2
description: Dry
- value: 4
description: Fan
- value: 8
description: Heat
- value: 9
description: Auto
- value: 10
description: Heat_cool
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c17:1:
prop.10.6:
unit: none
@ -125,11 +140,45 @@ urn:miot-spec-v2:device:curtain:0000A00C:bjkcz-kczble:1:0000D031:
name: status-a
urn:miot-spec-v2:device:electronic-valve:0000A0A7:sanmei-s1:1:
prop.3.1:
format: float
value-range:
- 0
- 99999999
- 0.01
expr: round(src_value/100, 2)
prop.3.2:
format: float
value-range:
- 0
- 16777216
- 0.01
expr: round(src_value/100, 2)
prop.3.3:
format: float
value-range:
- 0
- 65535
- 0.1
expr: round(src_value/10, 1)
urn:miot-spec-v2:device:electronic-valve:0000A0A7:ykcn-cbcs:1:0000C833:
prop.3.1:
format: float
value-range:
- 0
- 99999999
- 0.01
expr: round(src_value/100, 2)
prop.3.2:
unit: mA
prop.3.3:
format: float
value-range:
- 0
- 65535
- 0.1
expr: round(src_value/10, 1)
prop.4.1:
unit: kW
urn:miot-spec-v2:device:fan:0000A005:dmaker-p33:1:
prop.2.2:
name: fan-level-a
@ -205,6 +254,7 @@ urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:2: urn:miot-spec-v2:device:hood
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3:
prop.3.1:
name: on-ventilation
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:4: urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3
urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-ca4:2:
prop.2.7:
unit: percentage
@ -236,13 +286,30 @@ urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-acn001:1:
- read
- notify
unit: mV
urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-bmgl01:1:
prop.2.2:
value-list:
- value: 0
description: 0 Seconds
- value: 2
description: 2 Minutes
- value: 5
description: 5 Minutes
urn:miot-spec-v2:device:motor-controller:0000A01D:adp-adswb4:1:0000C837:
prop.2.1:
name: motor-switch
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:1: urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:2
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:2:
prop.2.5:
name: people-number
prop.2.8:
name: people-number
prop.2.11:
name: people-number
prop.2.14:
name: people-number
prop.2.17:
name: people-number
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:izq-24:2:0000C824:
prop.2.6:
unit: cm
@ -253,29 +320,57 @@ urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:1: urn:miot-spec-v2:devi
urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:2: urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3
urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3:
prop.5.1:
expr: round(src_value*6/1000000, 3)
format: float
value-range:
- 0
- 65535
- 0.01
expr: round(src_value*6/1000000, 2)
urn:miot-spec-v2:device:outlet:0000A002:cuco-cp1md:1:
prop.2.2:
name: power-consumption
expr: round(src_value/1000, 3)
format: float
value-range:
- 0
- 65535
- 0.01
expr: round(src_value/1000, 2)
prop.2.3:
format: float
value-range:
- 0
- 3000
- 0.1
expr: round(src_value/10, 1)
prop.2.4:
unit: mA
urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:1: urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:2
urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:2:
prop.2.3:
format: float
value-range:
- 0
- 3000
- 0.1
expr: round(src_value/10, 1)
prop.2.4:
unit: mA
prop.3.2:
format: float
value-range:
- 0
- 65535
- 0.1
expr: round(src_value/10, 1)
urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2d:1:
prop.3.2:
expr: round(src_value/1000, 2)
unit: mA
urn:miot-spec-v2:device:outlet:0000A002:cuco-v3:1:
prop.11.1:
name: power-consumption
format: float
value-range:
- 0
- 65535
- 0.01
expr: round(src_value/100, 2)
urn:miot-spec-v2:device:outlet:0000A002:cuco-v3:2: urn:miot-spec-v2:device:outlet:0000A002:cuco-v3:1
urn:miot-spec-v2:device:outlet:0000A002:giot-v8icm:1:0000C816:
@ -288,11 +383,20 @@ urn:miot-spec-v2:device:outlet:0000A002:qmi-psv3:1:0000C816:
unit: mA
urn:miot-spec-v2:device:outlet:0000A002:yutai-fsov8m:1:0000C816:
prop.4.1:
format: float
value-range:
- 0
- 429497
- 0.01
expr: round(src_value/10000, 2)
urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:1:0000C816: urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:2:0000C816
urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:2:0000C816:
prop.3.1:
name: electric-power
format: float
value-range:
- 0
- 350000
- 0.01
expr: round(src_value/100, 2)
urn:miot-spec-v2:device:plant-monitor:0000A030:hhcc-v1:1:
prop.2.1:
@ -325,10 +429,20 @@ urn:miot-spec-v2:device:switch:0000A003:090615-x1tpm:1:0000D042:
name: light-fan-on
urn:miot-spec-v2:device:switch:0000A003:lxzn-cbcsmj:1:0000D00D:
prop.3.1:
format: float
value-range:
- 0
- 99999999
- 0.01
expr: round(src_value/100, 2)
prop.3.2:
expr: round(src_value/1000, 2)
unit: mA
prop.3.3:
format: float
value-range:
- 0
- 65535
- 0.1
expr: round(src_value/10, 1)
urn:miot-spec-v2:device:thermostat:0000A031:suittc-wk168:1:
prop.2.3: