mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-21 01:39:36 +08:00
Compare commits
5 Commits
51eae7735d
...
167876442d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
167876442d | ||
|
|
001af5384a | ||
|
|
c8d48625e9 | ||
|
|
506bd9f52e | ||
|
|
7c0caa9df7 |
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,4 +1,16 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
## v0.4.7
|
||||||
|
### Added
|
||||||
|
- Add turkish language in multi_lang.json. [#1593](https://github.com/XiaoMi/ha_xiaomi_home/pull/1593)
|
||||||
|
### Changed
|
||||||
|
- Remove unused info getting from central hub gateway. [#1574](https://github.com/XiaoMi/ha_xiaomi_home/pull/1574)
|
||||||
|
- Remove xiaomi.router.rd03 from `UNSUPPORTED_MODELS` and add era.airp.cwb03, k0918.toothbrush.t700 into it. [#1567](https://github.com/XiaoMi/ha_xiaomi_home/pull/1567)
|
||||||
|
### Fixed
|
||||||
|
- Update the BLE mesh device online state from the central hub gateway. Partially fix the BLE mesh device online state. [#1579](https://github.com/XiaoMi/ha_xiaomi_home/pull/1579)
|
||||||
|
- Add unit for xiaomi.toothbrush.p001 brush-head-left-level property. [#1588](https://github.com/XiaoMi/ha_xiaomi_home/pull/1588)
|
||||||
|
- Fix the playing-state property's access field of xiaomi.wifispeaker.lx04, xiaomi.wifispeaker.lx06, xiaomi.wifispeaker.x08c and xiaomi.wifispeaker.l04m. [#1567](https://github.com/XiaoMi/ha_xiaomi_home/pull/1567)
|
||||||
|
- Fix the MIoT-Spec-V2 of xiaomi.airc.h09h00 humidity-range unit. [#1567](https://github.com/XiaoMi/ha_xiaomi_home/pull/1567)
|
||||||
|
|
||||||
## v0.4.6
|
## v0.4.6
|
||||||
### Added
|
### Added
|
||||||
- Add tv-box device as the media player entity. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
|
- Add tv-box device as the media player entity. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
|
||||||
@ -12,7 +24,7 @@
|
|||||||
- Catch paho-mqtt subscribe error properly. [#1551](https://github.com/XiaoMi/ha_xiaomi_home/pull/1551)
|
- Catch paho-mqtt subscribe error properly. [#1551](https://github.com/XiaoMi/ha_xiaomi_home/pull/1551)
|
||||||
- After the network resumes, keep retrying to fetch the device list until it succeeds. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
- After the network resumes, keep retrying to fetch the device list until it succeeds. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
||||||
- Catch the http post error properly. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
- Catch the http post error properly. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
||||||
- Fixed the format and the access field of daikin.aircondition.k2 and fix: daikin.airfresh.k33 string value properties. [#1561](https://github.com/XiaoMi/ha_xiaomi_home/pull/1561)
|
- Fix the format and the access field of daikin.aircondition.k2 and daikin.airfresh.k33 string value properties. [#1561](https://github.com/XiaoMi/ha_xiaomi_home/pull/1561)
|
||||||
|
|
||||||
## v0.4.5
|
## v0.4.5
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@ -349,3 +349,101 @@ async def async_remove_config_entry_device(
|
|||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
'remove device, %s, %s', identifiers[1], device_entry.id)
|
'remove device, %s, %s', identifiers[1], device_entry.id)
|
||||||
return True
|
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)
|
||||||
|
|||||||
@ -109,7 +109,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class XiaomiMihomeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
class XiaomiMihomeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
"""Xiaomi Home config flow."""
|
"""Xiaomi Home config flow."""
|
||||||
# pylint: disable=unused-argument, inconsistent-quotes
|
# pylint: disable=unused-argument, inconsistent-quotes
|
||||||
VERSION = 1
|
VERSION = 2
|
||||||
MINOR_VERSION = 1
|
MINOR_VERSION = 1
|
||||||
DEFAULT_AREA_NAME_RULE = 'room'
|
DEFAULT_AREA_NAME_RULE = 'room'
|
||||||
_main_loop: asyncio.AbstractEventLoop
|
_main_loop: asyncio.AbstractEventLoop
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
"cryptography",
|
"cryptography",
|
||||||
"psutil"
|
"psutil"
|
||||||
],
|
],
|
||||||
"version": "v0.4.6",
|
"version": "v0.4.7",
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
"_miot-central._tcp.local."
|
"_miot-central._tcp.local."
|
||||||
]
|
]
|
||||||
|
|||||||
@ -90,8 +90,9 @@ SUPPORTED_PLATFORMS: list = [
|
|||||||
|
|
||||||
UNSUPPORTED_MODELS: list = [
|
UNSUPPORTED_MODELS: list = [
|
||||||
'chuangmi.ir.v2',
|
'chuangmi.ir.v2',
|
||||||
|
'era.airp.cwb03',
|
||||||
'hmpace.motion.v6nfc',
|
'hmpace.motion.v6nfc',
|
||||||
'xiaomi.router.rd03'
|
'k0918.toothbrush.t700'
|
||||||
]
|
]
|
||||||
|
|
||||||
DEFAULT_CLOUD_SERVER: str = 'cn'
|
DEFAULT_CLOUD_SERVER: str = 'cn'
|
||||||
|
|||||||
@ -345,6 +345,11 @@ class MIoTDevice:
|
|||||||
f'{ha_domain}.{self._model_strs[0][:9]}_{self.did_tag}_'
|
f'{ha_domain}.{self._model_strs[0][:9]}_{self.did_tag}_'
|
||||||
f'{self._model_strs[-1][:20]}')
|
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,
|
def gen_service_entity_id(self, ha_domain: str, siid: int,
|
||||||
description: str) -> str:
|
description: str) -> str:
|
||||||
return (
|
return (
|
||||||
@ -682,58 +687,66 @@ class MIoTDevice:
|
|||||||
|
|
||||||
def unit_convert(self, spec_unit: str) -> Optional[str]:
|
def unit_convert(self, spec_unit: str) -> Optional[str]:
|
||||||
"""Convert MIoT unit to Home Assistant unit.
|
"""Convert MIoT unit to Home Assistant unit.
|
||||||
25/01/20: All online prop unit statistical tables: unit, quantity.
|
2026/01/06: property unit statistics of the latest released
|
||||||
|
MIoT-Spec-V2 for all device models: unit, quantity.
|
||||||
{
|
{
|
||||||
"no_unit": 148499,
|
"no_unit": 148499,
|
||||||
"percentage": 10042,
|
"percentage": 12074,
|
||||||
"kelvin": 1895,
|
"none": 11857,
|
||||||
"rgb": 772, // color
|
"minutes": 5707,
|
||||||
"celsius": 5762,
|
"celsius": 5767,
|
||||||
"none": 16106,
|
"seconds": 3062,
|
||||||
"hours": 1540,
|
"kelvin": 2511,
|
||||||
"minutes": 5061,
|
"hours": 1380,
|
||||||
"ms": 27,
|
"days": 615,
|
||||||
"watt": 216,
|
"rgb": 752, // color
|
||||||
"arcdegrees": 159,
|
"L": 379,
|
||||||
"ppm": 177,
|
"mg/m3": 335,
|
||||||
"μg/m3": 106,
|
"ppm": 182,
|
||||||
"days": 571,
|
"watt": 246,
|
||||||
"seconds": 2749,
|
"arcdegrees": 130,
|
||||||
|
"μg/m3": 117,
|
||||||
|
"kWh": 149,
|
||||||
|
"ms": 108,
|
||||||
|
"pascal": 108,
|
||||||
|
"lux": 100,
|
||||||
|
"V": 59,
|
||||||
|
"m": 45,
|
||||||
|
"A": 36,
|
||||||
|
"mL": 30,
|
||||||
|
"arcdegress": 25,
|
||||||
|
"mA": 26,
|
||||||
|
"bpm": 21, // realtime-heartrate
|
||||||
"B/s": 21,
|
"B/s": 21,
|
||||||
"pascal": 110,
|
"weeks": 18,
|
||||||
"mg/m3": 339,
|
"dB": 17,
|
||||||
"lux": 125,
|
"calorie": 18, // 1 cal = 4.184 J
|
||||||
"kWh": 124,
|
"metre": 15,
|
||||||
"mv": 2,
|
"hour": 11,
|
||||||
"V": 38,
|
"cm": 12,
|
||||||
"A": 29,
|
"gram": 8,
|
||||||
"mV": 4,
|
"km/h": 8,
|
||||||
"L": 352,
|
"mV": 9,
|
||||||
"m": 37,
|
"times": 4, // exercise-count
|
||||||
"毫摩尔每升": 2, // blood-sugar, cholesterol
|
"kCal": 4,
|
||||||
"mmol/L": 1, // urea
|
|
||||||
"weeks": 26,
|
|
||||||
"meter": 3,
|
|
||||||
"dB": 26,
|
|
||||||
"hour": 14,
|
|
||||||
"calorie": 19, // 1 cal = 4.184 J
|
|
||||||
"ppb": 3,
|
|
||||||
"arcdegress": 30,
|
|
||||||
"bpm": 4, // realtime-heartrate
|
|
||||||
"gram": 7,
|
|
||||||
"km/h": 9,
|
|
||||||
"W": 1,
|
|
||||||
"m3/h": 2,
|
|
||||||
"kilopascal": 1,
|
|
||||||
"mL": 4,
|
|
||||||
"mmHg": 4,
|
"mmHg": 4,
|
||||||
|
"pcs": 3,
|
||||||
|
"meter": 3,
|
||||||
|
"kW": 2,
|
||||||
|
"KByte/s": 2,
|
||||||
|
"毫摩尔每升": 2, // blood-sugar, cholesterol
|
||||||
|
"m3/h": 2,
|
||||||
|
"ppb": 2,
|
||||||
|
"mv": 2,
|
||||||
"w": 1,
|
"w": 1,
|
||||||
|
"bar": 1,
|
||||||
|
"megapascal": 1,
|
||||||
|
"kB": 1,
|
||||||
|
"mmol/L": 1, // urea
|
||||||
|
"min/km": 1,
|
||||||
|
"kilopascal": 1,
|
||||||
"liter": 1,
|
"liter": 1,
|
||||||
"cm": 3,
|
"W": 1
|
||||||
"mA": 2,
|
|
||||||
"kilogram": 2,
|
|
||||||
"kcal/d": 2, // basal-metabolism
|
|
||||||
"times": 1 // exercise-count
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
unit_map = {
|
unit_map = {
|
||||||
|
|||||||
@ -54,6 +54,9 @@ urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:1:
|
|||||||
prop.10.6:
|
prop.10.6:
|
||||||
unit: none
|
unit: none
|
||||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:1
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:1
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-h09h00:4:
|
||||||
|
prop.10.6:
|
||||||
|
unit: none
|
||||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-h40h00:1:
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-h40h00:1:
|
||||||
prop.10.6:
|
prop.10.6:
|
||||||
unit: none
|
unit: none
|
||||||
@ -499,6 +502,26 @@ urn:miot-spec-v2:device:safe-box:0000A042:loock-v1:1:
|
|||||||
prop.5.1:
|
prop.5.1:
|
||||||
name: contact-state
|
name: contact-state
|
||||||
expr: (src_value!=1)
|
expr: (src_value!=1)
|
||||||
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-l04m:2:
|
||||||
|
prop.3.1:
|
||||||
|
access:
|
||||||
|
- read
|
||||||
|
- notify
|
||||||
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx04:2:
|
||||||
|
prop.3.1:
|
||||||
|
access:
|
||||||
|
- read
|
||||||
|
- notify
|
||||||
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx06:2:
|
||||||
|
prop.3.1:
|
||||||
|
access:
|
||||||
|
- read
|
||||||
|
- notify
|
||||||
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-x08c:2:
|
||||||
|
prop.2.1:
|
||||||
|
access:
|
||||||
|
- read
|
||||||
|
- notify
|
||||||
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-x08e:1:
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-x08e:1:
|
||||||
prop.3.1:
|
prop.3.1:
|
||||||
name: playing-state-a
|
name: playing-state-a
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user