Compare commits

...

7 Commits

Author SHA1 Message Date
Ikko Eltociear Ashimine
4a02b1e067
Merge 5f41b15b7e into 5d4b975f85 2025-01-07 20:25:39 +08:00
Paul Shawn
5d4b975f85
fix: the number of profile models updated from 660 to 823 (#583)
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-01-07 20:22:06 +08:00
Paul Shawn
0566546a99
feat: filter miwifi.* devices (#564)
* feat: filter miwifi.* devices

* feat: update log level

* feat: filter special xiaomi router model, xiaomi.router.rd03
2025-01-07 20:21:43 +08:00
Paul Shawn
c0d100ce2b
feat: fan entity support direction ctrl (#556)
* feat: fan entity support direction

* fix: fix value judgement logic
2025-01-07 20:21:24 +08:00
Li Shuzhen
ce7ce7af4b
fix: fan speed (#464)
* fix: fan speed

* fix: fan speed names map

* fix: set percentage

* docs: the instance code format of valuelist

* fix: fan level property

* fix: pylint too long line.

* style: code format

---------

Co-authored-by: topsworld <sworldtop@gmail.com>
2025-01-07 20:21:04 +08:00
LiShuzhen
5f41b15b7e fix: doc path 2024-12-20 14:31:41 +08:00
Ikko Eltociear Ashimine
8fc19dab4a docs: add Japanese README
I created Japanese translated README.
2024-12-19 01:58:31 +09:00
8 changed files with 847 additions and 33 deletions

View File

@ -1,6 +1,6 @@
# Xiaomi Home Integration for Home Assistant # Xiaomi Home Integration for Home Assistant
[English](./README.md) | [简体中文](./doc/README_zh.md) [English](./README.md) | [简体中文](./doc/README_zh.md) | [日本語](./doc/README_ja.md)
Xiaomi Home Integration is an integrated component of Home Assistant supported by Xiaomi official. It allows you to use Xiaomi IoT smart devices in Home Assistant. Xiaomi Home Integration is an integrated component of Home Assistant supported by Xiaomi official. It allows you to use Xiaomi IoT smart devices in Home Assistant.
@ -351,7 +351,7 @@ The instance code is the code of the MIoT-Spec-V2 instance, which is in the form
``` ```
service:<siid> # service service:<siid> # service
service:<siid>:property:<piid> # property service:<siid>:property:<piid> # property
service:<siid>:property:<piid>:valuelist:<value> # the value in value-list of a property service:<siid>:property:<piid>:valuelist:<index> # The index of a value in the value-list of a property
service:<siid>:event:<eiid> # event service:<siid>:event:<eiid> # event
service:<siid>:action:<aiid> # action service:<siid>:action:<aiid> # action
``` ```

View File

@ -55,7 +55,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.components.fan import FanEntity, FanEntityFeature from homeassistant.components.fan import FanEntity, FanEntityFeature
from homeassistant.util.percentage import ( from homeassistant.util.percentage import (
percentage_to_ranged_value, percentage_to_ranged_value,
ranged_value_to_percentage ranged_value_to_percentage,
ordered_list_item_to_percentage,
percentage_to_ordered_list_item
) )
from .miot.miot_spec import MIoTSpecProperty from .miot.miot_spec import MIoTSpecProperty
@ -89,10 +91,15 @@ class Fan(MIoTServiceEntity, FanEntity):
_prop_fan_level: Optional[MIoTSpecProperty] _prop_fan_level: Optional[MIoTSpecProperty]
_prop_mode: Optional[MIoTSpecProperty] _prop_mode: Optional[MIoTSpecProperty]
_prop_horizontal_swing: Optional[MIoTSpecProperty] _prop_horizontal_swing: Optional[MIoTSpecProperty]
_prop_wind_reverse: Optional[MIoTSpecProperty]
_prop_wind_reverse_forward: Any
_prop_wind_reverse_reverse: Any
_speed_min: Optional[int] _speed_min: int
_speed_max: Optional[int] _speed_max: int
_speed_step: Optional[int] _speed_step: int
_speed_names: Optional[list]
_speed_name_map: Optional[dict[int, str]]
_mode_list: Optional[dict[Any, Any]] _mode_list: Optional[dict[Any, Any]]
def __init__( def __init__(
@ -101,15 +108,22 @@ class Fan(MIoTServiceEntity, FanEntity):
"""Initialize the Fan.""" """Initialize the Fan."""
super().__init__(miot_device=miot_device, entity_data=entity_data) super().__init__(miot_device=miot_device, entity_data=entity_data)
self._attr_preset_modes = [] self._attr_preset_modes = []
self._attr_current_direction = None
self._attr_supported_features = FanEntityFeature(0) self._attr_supported_features = FanEntityFeature(0)
self._prop_on = None self._prop_on = None
self._prop_fan_level = None self._prop_fan_level = None
self._prop_mode = None self._prop_mode = None
self._prop_horizontal_swing = None self._prop_horizontal_swing = None
self._prop_wind_reverse = None
self._prop_wind_reverse_forward = None
self._prop_wind_reverse_reverse = None
self._speed_min = 65535 self._speed_min = 65535
self._speed_max = 0 self._speed_max = 0
self._speed_step = 1 self._speed_step = 1
self._speed_names = []
self._speed_name_map = {}
self._mode_list = None self._mode_list = None
# properties # properties
@ -124,7 +138,8 @@ class Fan(MIoTServiceEntity, FanEntity):
self._speed_min = prop.value_range['min'] self._speed_min = prop.value_range['min']
self._speed_max = prop.value_range['max'] self._speed_max = prop.value_range['max']
self._speed_step = prop.value_range['step'] self._speed_step = prop.value_range['step']
self._attr_speed_count = self._speed_max - self._speed_min+1 self._attr_speed_count = int((
self._speed_max - self._speed_min)/self._speed_step)+1
self._attr_supported_features |= FanEntityFeature.SET_SPEED self._attr_supported_features |= FanEntityFeature.SET_SPEED
self._prop_fan_level = prop self._prop_fan_level = prop
elif ( elif (
@ -133,10 +148,13 @@ class Fan(MIoTServiceEntity, FanEntity):
and prop.value_list and prop.value_list
): ):
# Fan level with value-list # Fan level with value-list
for item in prop.value_list: # Fan level with value-range is prior to fan level with
self._speed_min = min(self._speed_min, item['value']) # value-list when a fan has both fan level properties.
self._speed_max = max(self._speed_max, item['value']) self._speed_name_map = {
self._attr_speed_count = self._speed_max - self._speed_min+1 item['value']: item['description']
for item in prop.value_list}
self._speed_names = list(self._speed_name_map.values())
self._attr_speed_count = len(prop.value_list)
self._attr_supported_features |= FanEntityFeature.SET_SPEED self._attr_supported_features |= FanEntityFeature.SET_SPEED
self._prop_fan_level = prop self._prop_fan_level = prop
elif prop.name == 'mode': elif prop.name == 'mode':
@ -156,6 +174,30 @@ class Fan(MIoTServiceEntity, FanEntity):
elif prop.name == 'horizontal-swing': elif prop.name == 'horizontal-swing':
self._attr_supported_features |= FanEntityFeature.OSCILLATE self._attr_supported_features |= FanEntityFeature.OSCILLATE
self._prop_horizontal_swing = prop self._prop_horizontal_swing = prop
elif prop.name == 'wind-reverse':
if prop.format_ == 'bool':
self._prop_wind_reverse_forward = False
self._prop_wind_reverse_reverse = True
elif (
isinstance(prop.value_list, list)
and prop.value_list
):
for item in prop.value_list:
if item['name'].lower() in {'foreward'}:
self._prop_wind_reverse_forward = item['value']
elif item['name'].lower() in {
'reversal', 'reverse'}:
self._prop_wind_reverse_reverse = item['value']
if (
self._prop_wind_reverse_forward is None
or self._prop_wind_reverse_reverse is None
):
# NOTICE: Value may be 0 or False
_LOGGER.info(
'invalid wind-reverse, %s', self.entity_id)
continue
self._attr_supported_features |= FanEntityFeature.DIRECTION
self._prop_wind_reverse = prop
def __get_mode_description(self, key: int) -> Optional[str]: def __get_mode_description(self, key: int) -> Optional[str]:
if self._mode_list is None: if self._mode_list is None:
@ -182,9 +224,19 @@ class Fan(MIoTServiceEntity, FanEntity):
await self.set_property_async(prop=self._prop_on, value=True) await self.set_property_async(prop=self._prop_on, value=True)
# percentage # percentage
if percentage: if percentage:
await self.set_property_async( if self._speed_names:
prop=self._prop_fan_level, speed = percentage_to_ordered_list_item(
value=int(percentage*self._attr_speed_count/100)) self._speed_names, percentage)
speed_value = self.get_map_value(
map_=self._speed_name_map, description=speed)
await self.set_property_async(
prop=self._prop_fan_level, value=speed_value)
else:
await self.set_property_async(
prop=self._prop_fan_level,
value=int(percentage_to_ranged_value(
low_high_range=(self._speed_min, self._speed_max),
percentage=percentage)))
# preset_mode # preset_mode
if preset_mode: if preset_mode:
await self.set_property_async( await self.set_property_async(
@ -202,11 +254,19 @@ class Fan(MIoTServiceEntity, FanEntity):
async def async_set_percentage(self, percentage: int) -> None: async def async_set_percentage(self, percentage: int) -> None:
"""Set the percentage of the fan speed.""" """Set the percentage of the fan speed."""
if percentage > 0: if percentage > 0:
await self.set_property_async( if self._speed_names:
prop=self._prop_fan_level, speed = percentage_to_ordered_list_item(
value=int(percentage_to_ranged_value( self._speed_names, percentage)
low_high_range=(self._speed_min, self._speed_max), speed_value = self.get_map_value(
percentage=percentage))) map_=self._speed_name_map, description=speed)
await self.set_property_async(
prop=self._prop_fan_level, value=speed_value)
else:
await self.set_property_async(
prop=self._prop_fan_level,
value=int(percentage_to_ranged_value(
low_high_range=(self._speed_min, self._speed_max),
percentage=percentage)))
if not self.is_on: if not self.is_on:
# If the fan is off, turn it on. # If the fan is off, turn it on.
await self.set_property_async(prop=self._prop_on, value=True) await self.set_property_async(prop=self._prop_on, value=True)
@ -221,6 +281,14 @@ class Fan(MIoTServiceEntity, FanEntity):
async def async_set_direction(self, direction: str) -> None: async def async_set_direction(self, direction: str) -> None:
"""Set the direction of the fan.""" """Set the direction of the fan."""
if not self._prop_wind_reverse:
return
await self.set_property_async(
prop=self._prop_wind_reverse,
value=(
self._prop_wind_reverse_reverse
if self.current_direction == 'reverse'
else self._prop_wind_reverse_forward))
async def async_oscillate(self, oscillating: bool) -> None: async def async_oscillate(self, oscillating: bool) -> None:
"""Oscillate the fan.""" """Oscillate the fan."""
@ -242,13 +310,28 @@ class Fan(MIoTServiceEntity, FanEntity):
key=self.get_prop_value(prop=self._prop_mode)) key=self.get_prop_value(prop=self._prop_mode))
if self._prop_mode else None) if self._prop_mode else None)
@property
def current_direction(self) -> Optional[str]:
"""Return the current direction of the fan."""
if not self._prop_wind_reverse:
return None
return 'reverse' if self.get_prop_value(
prop=self._prop_wind_reverse
) == self._prop_wind_reverse_reverse else 'forward'
@property @property
def percentage(self) -> Optional[int]: def percentage(self) -> Optional[int]:
"""Return the current percentage of the fan speed.""" """Return the current percentage of the fan speed."""
fan_level = self.get_prop_value(prop=self._prop_fan_level) fan_level = self.get_prop_value(prop=self._prop_fan_level)
return ranged_value_to_percentage( if fan_level is None:
low_high_range=(self._speed_min, self._speed_max), return None
value=fan_level) if fan_level else None if self._speed_names:
return ordered_list_item_to_percentage(
self._speed_names, self._speed_name_map[fan_level])
else:
return ranged_value_to_percentage(
low_high_range=(self._speed_min, self._speed_max),
value=fan_level)
@property @property
def oscillating(self) -> Optional[bool]: def oscillating(self) -> Optional[bool]:
@ -257,8 +340,3 @@ class Fan(MIoTServiceEntity, FanEntity):
self.get_prop_value( self.get_prop_value(
prop=self._prop_horizontal_swing) prop=self._prop_horizontal_swing)
if self._prop_horizontal_swing else None) if self._prop_horizontal_swing else None)
@property
def percentage_step(self) -> float:
"""Return the step of the fan speed."""
return self._speed_step

View File

@ -18,6 +18,10 @@
ts: 1603967572 ts: 1603967572
1245.airpurifier.dl01: 1245.airpurifier.dl01:
ts: 1607502661 ts: 1607502661
17216.magic_touch.d150:
ts: 1575097876
17216.magic_touch.d152:
ts: 1575097876
17216.massage.ec1266a: 17216.massage.ec1266a:
ts: 1615881124 ts: 1615881124
397.light.hallight: 397.light.hallight:
@ -56,6 +60,10 @@ bj352.airmonitor.m30:
ts: 1686644541 ts: 1686644541
bj352.waterpuri.s100cm: bj352.waterpuri.s100cm:
ts: 1615795630 ts: 1615795630
bymiot.gateway.v1:
ts: 1575097876
bymiot.gateway.v2:
ts: 1575097876
cgllc.airmonitor.b1: cgllc.airmonitor.b1:
ts: 1676339912 ts: 1676339912
cgllc.airmonitor.s1: cgllc.airmonitor.s1:
@ -64,6 +72,8 @@ cgllc.clock.cgc1:
ts: 1686644422 ts: 1686644422
cgllc.clock.dove: cgllc.clock.dove:
ts: 1619607474 ts: 1619607474
cgllc.gateway.s1:
ts: 1575097876
cgllc.magnet.hodor: cgllc.magnet.hodor:
ts: 1724329476 ts: 1724329476
cgllc.motion.cgpr1: cgllc.motion.cgpr1:
@ -120,8 +130,14 @@ chuangmi.cateye.ipc018:
ts: 1632735241 ts: 1632735241
chuangmi.cateye.ipc508: chuangmi.cateye.ipc508:
ts: 1633677521 ts: 1633677521
chuangmi.door.hmi508:
ts: 1611733437
chuangmi.door.hmi515: chuangmi.door.hmi515:
ts: 1640334316 ts: 1640334316
chuangmi.gateway.ipc011:
ts: 1575097876
chuangmi.ir.v2:
ts: 1575097876
chuangmi.lock.hmi501: chuangmi.lock.hmi501:
ts: 1614742147 ts: 1614742147
chuangmi.lock.hmi501b01: chuangmi.lock.hmi501b01:
@ -142,10 +158,18 @@ chuangmi.plug.v1:
ts: 1621925183 ts: 1621925183
chuangmi.plug.v3: chuangmi.plug.v3:
ts: 1644480255 ts: 1644480255
chuangmi.plug.vtl_v1:
ts: 1575097876
chuangmi.radio.v1: chuangmi.radio.v1:
ts: 1531108800 ts: 1531108800
chuangmi.radio.v2: chuangmi.radio.v2:
ts: 1531108800 ts: 1531108800
chuangmi.remote.h102a03:
ts: 1575097876
chuangmi.remote.h102c01:
ts: 1575097876
chuangmi.remote.v2:
ts: 1575097876
chunmi.cooker.eh1: chunmi.cooker.eh1:
ts: 1607339278 ts: 1607339278
chunmi.cooker.eh402: chunmi.cooker.eh402:
@ -204,6 +228,8 @@ dmaker.airfresh.t2017:
ts: 1686731233 ts: 1686731233
dmaker.fan.p5: dmaker.fan.p5:
ts: 1655793784 ts: 1655793784
doco.fcb.docov001:
ts: 1575097876
dsm.lock.h3: dsm.lock.h3:
ts: 1615283790 ts: 1615283790
dsm.lock.q3: dsm.lock.q3:
@ -218,6 +244,30 @@ fawad.airrtc.fwd20011:
ts: 1610607149 ts: 1610607149
fbs.airmonitor.pth02: fbs.airmonitor.pth02:
ts: 1686644918 ts: 1686644918
fengmi.projector.fm05:
ts: 1575097876
fengmi.projector.fm15:
ts: 1575097876
fengmi.projector.fm154k:
ts: 1575097876
fengmi.projector.l166:
ts: 1650352923
fengmi.projector.l176:
ts: 1649936204
fengmi.projector.l246:
ts: 1575097876
fengmi.projector.m055:
ts: 1652839826
fengmi.projector.m055d:
ts: 1654067980
fengyu.intercom.beebird:
ts: 1575097876
fengyu.intercom.sharkv1:
ts: 1575097876
fotile.hood.emd1tmi:
ts: 1607483642
guoshi.other.sem01:
ts: 1602662080
hannto.printer.anise: hannto.printer.anise:
ts: 1618989537 ts: 1618989537
hannto.printer.honey: hannto.printer.honey:
@ -226,14 +276,26 @@ hannto.printer.honey1s:
ts: 1614332725 ts: 1614332725
hfjh.fishbowl.v1: hfjh.fishbowl.v1:
ts: 1615278556 ts: 1615278556
hhcc.bleflowerpot.v2:
ts: 1575097876
hhcc.plantmonitor.v1: hhcc.plantmonitor.v1:
ts: 1664163526 ts: 1664163526
hith.foot_bath.q2: hith.foot_bath.q2:
ts: 1531108800 ts: 1531108800
hmpace.bracelet.v4:
ts: 1575097876
hmpace.scales.mibfs:
ts: 1575097876
hmpace.scales.miscale2:
ts: 1575097876
huohe.lock.m1: huohe.lock.m1:
ts: 1635410938 ts: 1635410938
huoman.litter_box.co1:
ts: 1687165034
hutlon.lock.v0001: hutlon.lock.v0001:
ts: 1634799698 ts: 1634799698
idelan.aircondition.g1:
ts: 1575097876
idelan.aircondition.v1: idelan.aircondition.v1:
ts: 1614666973 ts: 1614666973
idelan.aircondition.v2: idelan.aircondition.v2:
@ -248,14 +310,22 @@ ikea.light.led1537r6:
ts: 1605162872 ts: 1605162872
ikea.light.led1545g12: ikea.light.led1545g12:
ts: 1605162937 ts: 1605162937
ikea.light.led1546g12:
ts: 1575097876
ikea.light.led1623g12: ikea.light.led1623g12:
ts: 1605163009 ts: 1605163009
ikea.light.led1649c5: ikea.light.led1649c5:
ts: 1605163064 ts: 1605163064
ikea.light.led1650r5:
ts: 1575097876
imibar.cooker.mbihr3: imibar.cooker.mbihr3:
ts: 1624620659 ts: 1624620659
imou99.camera.tp2: imou99.camera.tp2:
ts: 1531108800 ts: 1531108800
inovel.projector.me2:
ts: 1575097876
iracc.aircondition.d19:
ts: 1609914362
isa.camera.df3: isa.camera.df3:
ts: 1531108800 ts: 1531108800
isa.camera.hl5: isa.camera.hl5:
@ -266,18 +336,34 @@ isa.camera.isc5:
ts: 1531108800 ts: 1531108800
isa.camera.isc5c1: isa.camera.isc5c1:
ts: 1621238175 ts: 1621238175
isa.camera.qf3:
ts: 1575097876
isa.cateye.hldb6:
ts: 1575097876
isa.magnet.dw2hl: isa.magnet.dw2hl:
ts: 1638274655 ts: 1638274655
jieman.magic_touch.js78:
ts: 1575097876
jiqid.mistory.ipen1:
ts: 1575097876
jiqid.mistory.pro: jiqid.mistory.pro:
ts: 1531108800 ts: 1531108800
jiqid.mistory.v1: jiqid.mistory.v1:
ts: 1531108800 ts: 1531108800
jiqid.mistudy.v2: jiqid.mistudy.v2:
ts: 1610612349 ts: 1610612349
jiqid.robot.cube:
ts: 1575097876
jiwu.lock.jwp01: jiwu.lock.jwp01:
ts: 1614752632 ts: 1614752632
jyaiot.cm.ccj01: jyaiot.cm.ccj01:
ts: 1611824545 ts: 1611824545
k0918.toothbrush.kid01:
ts: 1575097876
kejia.airer.th001:
ts: 1575097876
ksmb.treadmill.k12:
ts: 1575097876
ksmb.treadmill.v1: ksmb.treadmill.v1:
ts: 1611211447 ts: 1611211447
ksmb.treadmill.v2: ksmb.treadmill.v2:
@ -390,6 +476,8 @@ loock.lock.xfvl10:
ts: 1632814256 ts: 1632814256
loock.safe.v1: loock.safe.v1:
ts: 1619607755 ts: 1619607755
lumi.acpartner.mcn02:
ts: 1655791626
lumi.acpartner.v1: lumi.acpartner.v1:
ts: 1531108800 ts: 1531108800
lumi.acpartner.v2: lumi.acpartner.v2:
@ -462,6 +550,8 @@ lumi.lock.acn02:
ts: 1623928631 ts: 1623928631
lumi.lock.acn03: lumi.lock.acn03:
ts: 1614752574 ts: 1614752574
lumi.lock.aq1:
ts: 1612518044
lumi.lock.bacn01: lumi.lock.bacn01:
ts: 1614741699 ts: 1614741699
lumi.lock.bmcn02: lumi.lock.bmcn02:
@ -482,6 +572,8 @@ lumi.lock.mcn007:
ts: 1650446757 ts: 1650446757
lumi.lock.mcn01: lumi.lock.mcn01:
ts: 1679881881 ts: 1679881881
lumi.lock.v1:
ts: 1575097876
lumi.lock.wbmcn1: lumi.lock.wbmcn1:
ts: 1619422072 ts: 1619422072
lumi.motion.bmgl01: lumi.motion.bmgl01:
@ -510,14 +602,20 @@ lumi.sensor_86sw1.v1:
ts: 1609311038 ts: 1609311038
lumi.sensor_86sw2.v1: lumi.sensor_86sw2.v1:
ts: 1608795035 ts: 1608795035
lumi.sensor_cube.aqgl01:
ts: 1575097876
lumi.sensor_ht.v1: lumi.sensor_ht.v1:
ts: 1621239877 ts: 1621239877
lumi.sensor_magnet.aq2: lumi.sensor_magnet.aq2:
ts: 1641112867 ts: 1641112867
lumi.sensor_magnet.v1:
ts: 1606120416
lumi.sensor_magnet.v2: lumi.sensor_magnet.v2:
ts: 1641113779 ts: 1641113779
lumi.sensor_motion.aq2: lumi.sensor_motion.aq2:
ts: 1676433994 ts: 1676433994
lumi.sensor_motion.v1:
ts: 1605093075
lumi.sensor_motion.v2: lumi.sensor_motion.v2:
ts: 1672818550 ts: 1672818550
lumi.sensor_natgas.v1: lumi.sensor_natgas.v1:
@ -530,6 +628,8 @@ lumi.sensor_switch.aq2:
ts: 1615256430 ts: 1615256430
lumi.sensor_switch.aq3: lumi.sensor_switch.aq3:
ts: 1607399487 ts: 1607399487
lumi.sensor_switch.v1:
ts: 1606874434
lumi.sensor_switch.v2: lumi.sensor_switch.v2:
ts: 1609310683 ts: 1609310683
lumi.sensor_wleak.aq1: lumi.sensor_wleak.aq1:
@ -574,6 +674,20 @@ miaomiaoce.sensor_ht.t1:
ts: 1616057242 ts: 1616057242
miaomiaoce.sensor_ht.t2: miaomiaoce.sensor_ht.t2:
ts: 1636603553 ts: 1636603553
miaomiaoce.thermo.t01:
ts: 1575097876
midea.aircondition.v1:
ts: 1575097876
midea.aircondition.xa1:
ts: 1575097876
midea.aircondition.xa2:
ts: 1575097876
midr.rv_mirror.m2:
ts: 1575097876
midr.rv_mirror.m5:
ts: 1575097876
midr.rv_mirror.v1:
ts: 1575097876
miir.aircondition.ir01: miir.aircondition.ir01:
ts: 1531108800 ts: 1531108800
miir.aircondition.ir02: miir.aircondition.ir02:
@ -612,6 +726,8 @@ minij.washer.v5:
ts: 1622792196 ts: 1622792196
minij.washer.v8: minij.washer.v8:
ts: 1615777868 ts: 1615777868
minuo.tracker.lm001:
ts: 1575097876
miot.light.plato2: miot.light.plato2:
ts: 1685518142 ts: 1685518142
miot.light.plato3: miot.light.plato3:
@ -624,18 +740,32 @@ mmgg.feeder.snack:
ts: 1607503182 ts: 1607503182
moyu.washer.s1hm: moyu.washer.s1hm:
ts: 1624620888 ts: 1624620888
mrbond.airer.m0:
ts: 1575097876
mrbond.airer.m1pro: mrbond.airer.m1pro:
ts: 1646393746 ts: 1646393746
mrbond.airer.m1s: mrbond.airer.m1s:
ts: 1646393874 ts: 1646393874
mrbond.airer.m1super:
ts: 1575097876
msj.f_washer.m1: msj.f_washer.m1:
ts: 1614914340 ts: 1614914340
mxiang.cateye.mdb10: mxiang.cateye.mdb10:
ts: 1616140362 ts: 1616140362
mxiang.cateye.xmcatt1: mxiang.cateye.xmcatt1:
ts: 1616140207 ts: 1616140207
nhy.airrtc.v1:
ts: 1575097876
ninebot.scooter.v1:
ts: 1602662395
ninebot.scooter.v6:
ts: 1575097876
nuwa.robot.minikiwi:
ts: 1575097876
nwt.derh.wdh318efw1: nwt.derh.wdh318efw1:
ts: 1611822375 ts: 1611822375
onemore.wifispeaker.sm4:
ts: 1575097876
opple.light.bydceiling: opple.light.bydceiling:
ts: 1608187619 ts: 1608187619
opple.light.fanlight: opple.light.fanlight:
@ -646,6 +776,8 @@ opple.remote.5pb112:
ts: 1627453840 ts: 1627453840
opple.remote.5pb113: opple.remote.5pb113:
ts: 1636599905 ts: 1636599905
orion.wifispeaker.cm1:
ts: 1575097876
ows.towel_w.mj1x0: ows.towel_w.mj1x0:
ts: 1610604939 ts: 1610604939
philips.light.bceiling1: philips.light.bceiling1:
@ -696,6 +828,8 @@ pwzn.relay.apple:
ts: 1611217196 ts: 1611217196
pwzn.relay.banana: pwzn.relay.banana:
ts: 1646647255 ts: 1646647255
qicyc.bike.tdp02z:
ts: 1575097876
qike.bhf_light.qk201801: qike.bhf_light.qk201801:
ts: 1608174909 ts: 1608174909
qmi.powerstrip.v1: qmi.powerstrip.v1:
@ -726,8 +860,32 @@ roborock.vacuum.t6:
ts: 1619423841 ts: 1619423841
rockrobo.vacuum.v1: rockrobo.vacuum.v1:
ts: 1531108800 ts: 1531108800
roidmi.carairpuri.pro:
ts: 1575097876
roidmi.carairpuri.v1:
ts: 1575097876
roidmi.cleaner.f8pro:
ts: 1575097876
roidmi.cleaner.v1:
ts: 1575097876
roidmi.cleaner.v2:
ts: 1638514177
roidmi.cleaner.v382:
ts: 1575097876
roidmi.vacuum.v1:
ts: 1575097876
rokid.robot.me:
ts: 1575097876
rokid.robot.mini:
ts: 1575097876
rokid.robot.pebble:
ts: 1575097876
rokid.robot.pebble2:
ts: 1575097876
roome.bhf_light.yf6002: roome.bhf_light.yf6002:
ts: 1531108800 ts: 1531108800
rotai.magic_touch.sx300:
ts: 1602662578
rotai.massage.rt5728: rotai.massage.rt5728:
ts: 1610607000 ts: 1610607000
rotai.massage.rt5850: rotai.massage.rt5850:
@ -738,22 +896,42 @@ rotai.massage.rt5863:
ts: 1611827937 ts: 1611827937
rotai.massage.rt5870: rotai.massage.rt5870:
ts: 1632376570 ts: 1632376570
runmi.suitcase.v1:
ts: 1575097876
scishare.coffee.s1102: scishare.coffee.s1102:
ts: 1611824402 ts: 1611824402
shjszn.gateway.c1:
ts: 1575097876
shjszn.lock.c1:
ts: 1575097876
shjszn.lock.kx:
ts: 1575097876
shuii.humidifier.jsq001:
ts: 1575097876
shuii.humidifier.jsq002: shuii.humidifier.jsq002:
ts: 1606376290 ts: 1606376290
skyrc.feeder.dfeed:
ts: 1626082349
skyrc.pet_waterer.fre1: skyrc.pet_waterer.fre1:
ts: 1608186812 ts: 1608186812
smith.w_soften.cxs05ta1:
ts: 1575097876
smith.waterheater.cxea1: smith.waterheater.cxea1:
ts: 1611826349 ts: 1611826349
smith.waterheater.cxeb1: smith.waterheater.cxeb1:
ts: 1611826388 ts: 1611826388
smith.waterpuri.jnt600: smith.waterpuri.jnt600:
ts: 1531108800 ts: 1531108800
soocare.toothbrush.m1:
ts: 1575097876
soocare.toothbrush.m1s: soocare.toothbrush.m1s:
ts: 1610611310 ts: 1610611310
soocare.toothbrush.mc1:
ts: 1575097876
soocare.toothbrush.t501: soocare.toothbrush.t501:
ts: 1672192586 ts: 1672192586
soocare.toothbrush.x3:
ts: 1575097876
sxds.pillow.pillow02: sxds.pillow.pillow02:
ts: 1611222235 ts: 1611222235
syniot.curtain.syc1: syniot.curtain.syc1:
@ -778,6 +956,10 @@ tokit.oven.tk32pro1:
ts: 1617002408 ts: 1617002408
tokit.pre_cooker.tkih1: tokit.pre_cooker.tkih1:
ts: 1607410832 ts: 1607410832
trios1.bleshoes.v02:
ts: 1602662599
txdd.wifispeaker.x1:
ts: 1575097876
viomi.aircondition.v10: viomi.aircondition.v10:
ts: 1606375041 ts: 1606375041
viomi.aircondition.v21: viomi.aircondition.v21:
@ -830,12 +1012,16 @@ viomi.fridge.u13:
ts: 1614667152 ts: 1614667152
viomi.fridge.u15: viomi.fridge.u15:
ts: 1607505693 ts: 1607505693
viomi.fridge.u17:
ts: 1575097876
viomi.fridge.u18: viomi.fridge.u18:
ts: 1614655755 ts: 1614655755
viomi.fridge.u2: viomi.fridge.u2:
ts: 1531108800 ts: 1531108800
viomi.fridge.u24: viomi.fridge.u24:
ts: 1614667214 ts: 1614667214
viomi.fridge.u25:
ts: 1575097876
viomi.fridge.u4: viomi.fridge.u4:
ts: 1614667295 ts: 1614667295
viomi.fridge.u6: viomi.fridge.u6:
@ -992,6 +1178,82 @@ xiaomi.aircondition.ma6:
ts: 1721629272 ts: 1721629272
xiaomi.aircondition.ma9: xiaomi.aircondition.ma9:
ts: 1721629362 ts: 1721629362
xiaomi.plc.v1:
ts: 1575097876
xiaomi.repeater.v1:
ts: 1575097876
xiaomi.repeater.v2:
ts: 1575097876
xiaomi.repeater.v3:
ts: 1575097876
xiaomi.router.d01:
ts: 1575097876
xiaomi.router.lv1:
ts: 1575097876
xiaomi.router.lv3:
ts: 1575097876
xiaomi.router.mv1:
ts: 1575097876
xiaomi.router.r2100:
ts: 1575097876
xiaomi.router.r3600:
ts: 1575097876
xiaomi.router.r3a:
ts: 1575097876
xiaomi.router.r3d:
ts: 1575097876
xiaomi.router.r3g:
ts: 1575097876
xiaomi.router.r3gv2:
ts: 1575097876
xiaomi.router.r3gv2n:
ts: 1575097876
xiaomi.router.r3p:
ts: 1575097876
xiaomi.router.r4:
ts: 1575097876
xiaomi.router.r4a:
ts: 1575097876
xiaomi.router.r4ac:
ts: 1575097876
xiaomi.router.r4c:
ts: 1575097876
xiaomi.router.r4cm:
ts: 1575097876
xiaomi.router.rm1800:
ts: 1575097876
xiaomi.router.v1:
ts: 1575097876
xiaomi.router.v2:
ts: 1575097876
xiaomi.router.v3:
ts: 1575097876
xiaomi.split_tv.b1:
ts: 1575097876
xiaomi.split_tv.v1:
ts: 1575097876
xiaomi.tv.b1:
ts: 1661248580
xiaomi.tv.h1:
ts: 1575097876
xiaomi.tv.i1:
ts: 1661248572
xiaomi.tv.v1:
ts: 1670811870
xiaomi.tvbox.b1:
ts: 1694503508
xiaomi.tvbox.i1:
ts: 1694503515
xiaomi.tvbox.v1:
ts: 1694503501
xiaomi.watch.band1:
ts: 1575097876
xiaomi.watch.band1A:
ts: 1575097876
xiaomi.watch.band1S:
ts: 1575097876
xiaomi.watch.band2:
ts: 1575097876
xiaomi.wifispeaker.l04m: xiaomi.wifispeaker.l04m:
ts: 1658817956 ts: 1658817956
xiaomi.wifispeaker.l06a: xiaomi.wifispeaker.l06a:
@ -1012,6 +1274,10 @@ xiaomi.wifispeaker.lx5a:
ts: 1672299577 ts: 1672299577
xiaomi.wifispeaker.s12: xiaomi.wifispeaker.s12:
ts: 1672299594 ts: 1672299594
xiaomi.wifispeaker.v1:
ts: 1575097876
xiaomi.wifispeaker.v3:
ts: 1575097876
xiaomi.wifispeaker.x08a: xiaomi.wifispeaker.x08a:
ts: 1672818945 ts: 1672818945
xiaomi.wifispeaker.x08c: xiaomi.wifispeaker.x08c:
@ -1028,6 +1294,44 @@ xiaovv.camera.xvd5:
ts: 1531108800 ts: 1531108800
xiaovv.camera.xvsnowman: xiaovv.camera.xvsnowman:
ts: 1531108800 ts: 1531108800
xiaoxun.robot.v1:
ts: 1575097876
xiaoxun.tracker.v1:
ts: 1575097876
xiaoxun.watch.sw306:
ts: 1575097876
xiaoxun.watch.sw560:
ts: 1575097876
xiaoxun.watch.sw705:
ts: 1575097876
xiaoxun.watch.sw710a2:
ts: 1575097876
xiaoxun.watch.sw760:
ts: 1575097876
xiaoxun.watch.sw900:
ts: 1575097876
xiaoxun.watch.sw960:
ts: 1575097876
xiaoxun.watch.v1:
ts: 1575097876
xiaoxun.watch.v10:
ts: 1575097876
xiaoxun.watch.v11:
ts: 1575097876
xiaoxun.watch.v2:
ts: 1575097876
xiaoxun.watch.v3:
ts: 1575097876
xiaoxun.watch.v4:
ts: 1575097876
xiaoxun.watch.v5:
ts: 1575097876
xiaoxun.watch.v7:
ts: 1575097876
xiaoxun.watch.v8:
ts: 1575097876
xiaoxun.watch.v9:
ts: 1575097876
xjx.toilet.pro: xjx.toilet.pro:
ts: 1615965466 ts: 1615965466
xjx.toilet.pure: xjx.toilet.pure:
@ -1054,6 +1358,8 @@ yeelink.bhf_light.v3:
ts: 1608790102 ts: 1608790102
yeelink.bhf_light.v5: yeelink.bhf_light.v5:
ts: 1601292562 ts: 1601292562
yeelink.gateway.v1:
ts: 1575097876
yeelink.light.bslamp1: yeelink.light.bslamp1:
ts: 1703120679 ts: 1703120679
yeelink.light.bslamp2: yeelink.light.bslamp2:
@ -1192,6 +1498,10 @@ yunmi.kettle.r2:
ts: 1606372087 ts: 1606372087
yunmi.kettle.r3: yunmi.kettle.r3:
ts: 1637309534 ts: 1637309534
yunmi.kettle.v1:
ts: 1575097876
yunmi.kettle.v9:
ts: 1602662686
yunmi.plmachine.mg2: yunmi.plmachine.mg2:
ts: 1611833658 ts: 1611833658
yunmi.waterpuri.c5: yunmi.waterpuri.c5:
@ -1230,18 +1540,26 @@ yunmi.waterpurifier.v2:
ts: 1632377061 ts: 1632377061
yunmi.waterpurifier.v3: yunmi.waterpurifier.v3:
ts: 1611221428 ts: 1611221428
yunyi.camera.v1:
ts: 1575097876
yyunyi.wopener.yypy24: yyunyi.wopener.yypy24:
ts: 1616741966 ts: 1616741966
yyzhn.gateway.yn181126:
ts: 1610689325
zdeer.ajh.a8: zdeer.ajh.a8:
ts: 1531108800 ts: 1531108800
zdeer.ajh.a9: zdeer.ajh.a9:
ts: 1531108800 ts: 1531108800
zdeer.ajh.ajb:
ts: 1608276454
zdeer.ajh.zda10: zdeer.ajh.zda10:
ts: 1531108800 ts: 1531108800
zdeer.ajh.zda9: zdeer.ajh.zda9:
ts: 1531108800 ts: 1531108800
zdeer.ajh.zjy: zdeer.ajh.zjy:
ts: 1531108800 ts: 1531108800
zhij.toothbrush.bv1:
ts: 1575097876
zhimi.aircondition.ma1: zhimi.aircondition.ma1:
ts: 1615185265 ts: 1615185265
zhimi.aircondition.ma3: zhimi.aircondition.ma3:
@ -1250,6 +1568,8 @@ zhimi.aircondition.ma4:
ts: 1626334057 ts: 1626334057
zhimi.aircondition.v1: zhimi.aircondition.v1:
ts: 1610610931 ts: 1610610931
zhimi.aircondition.v2:
ts: 1575097876
zhimi.aircondition.va1: zhimi.aircondition.va1:
ts: 1609924720 ts: 1609924720
zhimi.aircondition.za1: zhimi.aircondition.za1:
@ -1276,8 +1596,12 @@ zhimi.airpurifier.sa2:
ts: 1635820002 ts: 1635820002
zhimi.airpurifier.v1: zhimi.airpurifier.v1:
ts: 1635855633 ts: 1635855633
zhimi.airpurifier.v2:
ts: 1575097876
zhimi.airpurifier.v3: zhimi.airpurifier.v3:
ts: 1676339933 ts: 1676339933
zhimi.airpurifier.v5:
ts: 1575097876
zhimi.airpurifier.v6: zhimi.airpurifier.v6:
ts: 1636978652 ts: 1636978652
zhimi.airpurifier.v7: zhimi.airpurifier.v7:
@ -1318,3 +1642,5 @@ zimi.mosq.v1:
ts: 1620728957 ts: 1620728957
zimi.powerstrip.v2: zimi.powerstrip.v2:
ts: 1620812714 ts: 1620812714
zimi.projector.v1:
ts: 1575097876

View File

@ -531,9 +531,18 @@ class MIoTHttpClient:
name = device.get('name', None) name = device.get('name', None)
urn = device.get('spec_type', None) urn = device.get('spec_type', None)
model = device.get('model', None) model = device.get('model', None)
if did is None or name is None or urn is None or model is None: if did is None or name is None:
_LOGGER.error( _LOGGER.info(
'get_device_list, cloud, invalid device, %s', device) 'invalid device, cloud, %s', device)
continue
if urn is None or model is None:
_LOGGER.info(
'missing the urn|model field, cloud, %s', device)
continue
if did.startswith('miwifi.'):
# The miwifi.* routers defined SPEC functions, but none of them
# were implemented.
_LOGGER.info('ignore miwifi.* device, cloud, %s', did)
continue continue
device_infos[did] = { device_infos[did] = {
'did': did, 'did': did,
@ -634,7 +643,7 @@ class MIoTHttpClient:
for did in dids: for did in dids:
if did not in results: if did not in results:
devices.pop(did, None) devices.pop(did, None)
_LOGGER.error('get device info failed, %s', did) _LOGGER.info('get device info failed, %s', did)
continue continue
devices[did].update(results[did]) devices[did].update(results[did])
# Whether sub devices # Whether sub devices

View File

@ -59,5 +59,10 @@
"1", "1",
"5" "5"
] ]
},
"urn:miot-spec-v2:device:router:0000A036:xiaomi-rd03": {
"services": [
"*"
]
} }
} }

View File

@ -289,7 +289,7 @@ SPEC_SERVICE_TRANS_MAP: dict[str, dict | str] = {
} }
}, },
'optional': { 'optional': {
'properties': {'mode', 'horizontal-swing'} 'properties': {'mode', 'horizontal-swing', 'wind-reverse'}
}, },
'entity': 'fan' 'entity': 'fan'
}, },

396
doc/README_ja.md Normal file
View File

@ -0,0 +1,396 @@
# Home Assistant Xiaomi Home Integration
[English](../README.md) | [简体中文](./README_zh.md) | [日本語](./README_ja.md)
Xiaomi Home Integrationは、Xiaomi公式がサポートするHome Assistantの統合コンポーネントであり、Home AssistantでXiaomi IoTスマートデバイスを使用できるようにします。
## インストール
> Home Assistantのバージョン要件
>
> - Core $\geq$ 2024.11.0
> - Operating System $\geq$ 13.0
### 方法1GitHubからgit cloneコマンドを使用してダウンロード
```bash
cd config
git clone https://github.com/XiaoMi/ha_xiaomi_home.git
cd ha_xiaomi_home
./install.sh /config
```
この方法でXiaomi Home Integrationをインストールすることをお勧めします。特定のバージョンに更新したい場合は、対応するタグに切り替えるだけです。
Xiaomi Home Integrationのバージョンをv1.0.0に更新する
```bash
cd config/ha_xiaomi_home
git checkout v1.0.0
./install.sh /config
```
### 方法2[HACS](https://hacs.xyz/)
HACS > オーバーフローメニュー > カスタムリポジトリ > リポジトリhttps://github.com/XiaoMi/ha_xiaomi_home.git & カテゴリIntegration > 追加
> Xiaomi HomeはまだHACSストアにデフォルトとして追加されていません。近日中に追加予定です。
### 方法3[Samba](https://github.com/home-assistant/addons/tree/master/samba)または[FTPS](https://github.com/hassio-addons/addon-ftp)を使用して手動でインストール
ダウンロードして、`custom_components/xiaomi_home`フォルダをHome Assistantの`config/custom_components`フォルダにコピーします。
## 設定
### ログイン
[設定 > デバイスとサービス > 統合を追加](https://my.home-assistant.io/redirect/brand/?brand=xiaomi_home) > `Xiaomi Home`を検索 > 次へ > ここをクリックしてログイン > Xiaomiアカウントでサインイン
[![Open your Home Assistant instance and start setting up a new integration.](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start/?domain=xiaomi_home)
### MIoTデバイスを追加
ログインに成功すると、「家庭とデバイスを選択」ダイアログボックスが表示されます。Home Assistantにインポートしたいデバイスを含む家庭を選択できます。
### 複数ユーザーログイン
Xiaomiアカウントのログインとユーザー設定が完了した後、設定済みのXiaomi Home Integrationページで他のXiaomiアカウントを追加できます。
方法:[設定 > デバイスとサービス > 設定済み > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 中枢を追加 > 次へ > ここをクリックしてログイン > Xiaomiアカウントでサインイン
[![Open your Home Assistant instance and show an integration.](https://my.home-assistant.io/badges/integration.svg)](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home)
### 設定の更新
「設定オプション」ダイアログボックスで設定を変更できます。ユーザーのニックネームやXiaomi Home APPからインポートするデバイスのリストなどを更新できます。
方法:[設定 > デバイスとサービス > 設定済み > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 設定 > 更新するオプションを選択
### アクションのデバッグモード
アクションのデバッグモードを有効にすると、パラメータ付きのアクションコマンドメッセージをデバイスに手動で送信できます。パラメータ付きのアクションコマンドを送信するためのユーザーインターフェースは、テキストエンティティとして表示されます。
方法:[設定 > デバイスとサービス > 設定済み > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 設定 > アクションのデバッグモード
## セキュリティ
Xiaomi Home Integrationと関連するクラウドインターフェースは、Xiaomi公式が提供しています。デバイスリストを取得するためにXiaomiアカウントを使用してログインする必要があります。Xiaomi Home IntegrationはOAuth 2.0のログインプロセスを実装しており、Home Assistantアプリケーションにアカウントのパスワードを保存しません。ただし、Home Assistantプラットフォームの制限により、ログインに成功した後、Xiaomiアカウントのユーザー情報デバイス情報、証明書、トークンなどがHome Assistantの設定ファイルに平文で保存されます。Home Assistantの設定ファイルを適切に保管する必要があります。設定ファイルが漏洩すると、他の人があなたの身元でログインする可能性があります。
## FAQ
- Xiaomi Home IntegrationはすべてのXiaomi Homeデバイスをサポートしていますか
Xiaomi Home Integrationは現在、ほとんどのXiaomi Homeデバイスカテゴリをサポートしていますが、Bluetoothデバイス、赤外線デバイス、仮想デバイスなどの一部のカテゴリはサポートしていません。
- Xiaomi Home Integrationは複数のXiaomiアカウントをサポートしていますか
はい、複数のXiaomiアカウントをサポートしています。さらに、Xiaomi Home Integrationは、異なるアカウントに属するデバイスを同じエ<E38198><E382A8><EFBFBD>アに追加することができます。
- Xiaomi Home Integrationはローカルコントロールをサポートしていますか
ローカルコントロールは、[Xiaomi Central Hub Gateway](https://www.mi.com/shop/buy/detail?product_id=15755&cfrom=search)ファームウェアバージョン3.4.0_0000以上または内蔵の中央ハブゲートウェイソフトウェアバージョン0.8.0以上を持つXiaomi Homeデバイスによって実装されます。Xiaomi Central Hub Gatewayまたは中央ハブゲートウェイ機能を持つ他のデバイスがない場合、すべてのコントロールコマンドはXiaomi Cloudを介して送信されます。Home Assistantのローカルコントロール機能をサポートするXiaomi Central Hub Gateway内蔵中央ハブゲートウェイを含むのファームウェアはまだリリースされていません。アップグレード計画については、MIoTチーム<E383BC><E383A0>通知を参照してください。
Xiaomi Central Hub Gatewayは中国本土でのみ利用可能であり、他の地域では利用できません。
Xiaomi Home Integrationは、Xiaomi LANコントロール機能を有効にすることで部分的なローカルコントロールを実装することもできます。Xiaomi LANコントロール機能は、Home Assistantと同じローカルエリアネットワーク内のIPデバイスWiFiまたはイーサネットケーブルでルーターに接続されたデバイスのみを制御できます。BLE Mesh、ZigBeeなどのデバイスは制御できません。この機能は一部の異常を引き起こす可能性があります。この機能を使用しないことをお勧めします。Xiaomi LANコントロール機能は、[設定 > デバイスとサービス > 設定済み > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 設定 > LANコントロール設定の更新で有効にできます。
Xiaomi LANコントロール機能は地域制限がなく、すべての地域で利用可能です。ただし、Home Assistantが存在するローカルエリアネットワーク内に中央ゲートウェイがある場合、統合でXiaomi LANコントロール機能が有効になっていても、機能は有効になりません。
- Xiaomi Home Integrationはどの地域で利用可能ですか
Xiaomi Home Integrationは、中国本土、ヨーロッパ、インド、ロシア、シンガポール、アメリカの6つの地域で利用できます。異なる地域のXiaomi Cloudのユーザーデータは相互に隔離されているため、設定プロセスでMIoTデバイスをインポートする際に地域を選択する必要があります。Xiaomi Home Integrationは、異なる地域のデバイスを同じエリアにインポートすることができます。
## メッセージングの原理
### クラウドを介したコントロール
<div align=center>
<img src="./images/cloud_control.jpg" width=300>
図1クラウドコントロールアーキテクチャ
</div>
Xiaomi Home Integrationは、MIoT CloudのMQTT Brokerで関心のあるデバイスメッセージを購読します。デバイスのプロパティが変更されたり、デバイスイベントが発生したりすると、デバイスはMIoT Cloudに上りメッセージを送信し、MQTT Brokerは購読されたデバイスメッセージをXiaomi Home Integrationにプッシュします。Xiaomi Home Integrationは、クラウドで現在のデバイスプロパティ値を取得するためにポーリングする必要がないため、プロパティが変更されたりイベントが発生したりするとすぐに通知メッセージを受信できます。メッセージ購読メカニズムのおかげで、Xiaomi Home Integrationは、統合設定が完了したときにクラウドからすべてのデバイスのプロパティを一度だけクエリし、クラウドへのアクセス圧力はほとんどありません。
Xiaomi Home Integrationは、MIoT CloudのHTTPインター<E382BF><E383BC><EFBFBD>ェースを介してデバイスにコマンドメッセージを送信してデバイスを制御します。デバイスは、MIoT Cloudから送信された下りメッセージを受信した後に反応し、応答します。
### ローカルでのコントロール
<div align=center>
<img src="./images/local_control.jpg" width=300>
図2ローカルコントロールアーキテクチャ
</div>
Xiaomi Central Hub Gatewayには標準のMQTT Brokerが含まれており、完全な購読公開メカニズムを実装しています。Xiaomi Home Integrationは、Xiaomi Central Hub Gatewayを介して関心のあるデバイスメッセージを購読します。デバイスのプロパティが変更されたり、デバイスイベントが発生したりすると、デバイスはXiaomi Central Hub Gatewayに上りメッセージを送信し、MQTT Brokerは購読されたデバイスメッセージをXiaomi Home Integrationにプッシュします。
Xiaomi Home Integrationがデバイスを制御する必要がある場合、MQTT Brokerにデバイスコマンドメッセージを公開し、Xiaomi Central Hub Gatewayがデバイスに転送します。デバイスは、ゲートウェイから送信された下りメッセージを<E382B8><E38292><EFBFBD>信した後に反応し、応答します。
## MIoT-Spec-V2とHome Assistantエンティティのマッピング関係
[MIoT-Spec-V2](https://iot.mi.com/v2/new/doc/introduction/knowledge/spec)は、MIoT Specification Version 2の略であり、Xiaomi IoTプラットフォームが策定したIoTプロトコルであり、IoTデバイスの機能を標準的に記述するために使用されます。これには、機能定義他のIoTプラットフォームではデータモデルと呼ばれる、インタラクションモデル、メッセージ形式、およびエンコーディングが含まれます。
MIoT-Spec-V2プロトコルでは、製品はデバイスとして定義されます。デバイスにはいくつかのサービスが含まれます。サービスにはいくつかのプロパティ、イベント、およびアクションが含まれる場合があります。Xiaomi Home Integrationは、MIoT-Spec-V2に従ってHome Assistantエンティティを作成します。変換関係は次のとおりです。
### 一般的な変換
- プロパティ
| フォーマット | アクセス | 値リスト | 値範囲 | Home Assistantのエンティティ |
| ------------ | -------- | -------- | ------ | ---------------------------- |
| 書き込み可能 | 文字列 | - | - | テキスト |
| 書き込み可能 | ブール | - | - | スイッチ |
| 書き込み可能 | 文字列以外 & ブール以外 | 存在する | - | セレクト |
| 書き込み可能 | 文字列以外 & ブール以外 | 存在しない | 存在する | ナンバー |
| 書き込み不可 | - | - | - | センサー |
- イベント
MIoT-Spec-V2イベントは、Home Assistantのイベントエンティティに変換されます。イベントのパラメータもエンティティの`_trigger_event`に渡されます。
- アクション
| in | Home Assistantのエンティティ |
| --------- | ---------------------------- |
| 空 | ボタン |
| 空でない | 通知 |
アクションのデバッグモードが有効になっている場合、アクションの`in`フィールドが空でない場合、テキストエンティティも作成されます。
エンティティの詳細ページの「属性」項目には、入力パラメータの形式が表示されます。入力パラメータは順序付きリストであり、角括弧[]で囲まれています。リスト内の文字列要素は二重引用符""で囲まれています。
xiaomi.wifispeaker.s12 siid=5 aiid=5インスタンスの「Intelligent Speaker Execute Text Directive」アクションによって変換された通知エンティティの詳細ページの「属性」項目には、アクションパラメータとして`[Text Content(str), Silent Execution(bool)]`が表示されます。適切にフォーマットされた入力は`["Hello", true]`です。
### 特定の変換
MIoT-Spec-V2は、タイプを定義するためにURNを使用します。形式は`urn:<namespace>:<type>:<name>:<value>[:<vendor-product>:<version>]`であり、`name`はデバイス、サービス、プロパティ、イベント、アクションのインスタンスを説明するための人間が読める単語またはフレーズです。Xiaomi Home Integrationは、インスタンスの名前に基づいてMIoT-Spec-V2インスタンスを特定のHome Assistantエンティティに変換するかどうかを最初に判断します。特定の変換ルールに一致しないインスタンスについては、一般的な変換ルールを使用して変換します。
`namespace`はMIoT-Spec-V2インスタンスの名前空間です。その値がmiot-spec-v2の場合、仕様はXiaomiによって定義されたことを意味します。その値がbluetooth-specの場合、仕様はBluetooth Special Interest GroupSIGによって定義されたことを意味します。その値がmiot-spec-v2またはbluetooth-specでない場合、仕様は他のベンダーによって定義されたことを意味します。MIoT-Spec-V2の`namespace`がmiot-spec-v2でない場合、エンティティの名前の前に星印`*`が追加されます。
- デバイス
変換は`SPEC_DEVICE_TRANS_MAP`に従います。
```
{
'<device instance name>':{
'required':{
'<service instance name>':{
'required':{
'properties': {
'<property instance name>': set<property access: str>
},
'events': set<event instance name: str>,
'actions': set<action instance name: str>
},
'optional':{
'properties': set<property instance name: str>,
'events': set<event instance name: str>,
'actions': set<action instance name: str>
}
}
},
'optional':{
'<service instance name>':{
'required':{
'properties': {
'<property instance name>': set<property access: str>
},
'events': set<event instance name: str>,
'actions': set<action instance name: str>
},
'optional':{
'properties': set<property instance name: str>,
'events': set<event instance name: str>,
'actions': set<action instance name: str>
}
}
},
'entity': str
}
}
```
"device instance name"の下の"required"フィールドは、デバイスの必須サービスを示します。"optional"フィールドは、デバイスのオプションサービスを示します。"entity"フィールドは、作成されるHome Assistantエンティティを示します。"service instance name"の下の"required"フィールドと"optional"フィールドは、それぞれサービスの必須プロパティ、イベント、およびアクションを示します。"required"フィールドの"properties"フィールドの"property instance name"の値は、プロパティのアクセスモードです。成功した一致の条件は、"property instance name"の値が対応するMIoT-Spec-V2プロパティインスタンスのアクセスモードのサブセットであることです。
MIoT-Spec-V2デバイスインスタンスがすべての必須サービス、プロパティ、イベント、アクションを含まない場合、Home Assistantエンティティは作成されません。
- サービス
変換は`SPEC_SERVICE_TRANS_MAP`に従います。
```
{
'<service instance name>':{
'required':{
'properties': {
'<property instance name>': set<property access: str>
},
'events': set<event instance name: str>,
'actions': set<action instance name: str>
},
'optional':{
'properties': set<property instance name: str>,
'events': set<event instance name: str>,
'actions': set<action instance name: str>
},
'entity': str
}
}
```
"service instance name"の下の"required"フィールドは、サービスの必須プロパティ、イベント、およびアクションを示します。"optional"フィールドは、サービスのオプションプロパティ、イベント、およびアクションを示します。"entity"フィールドは、作成されるHome Assistantエンティティを示します。"required"フィールドの"properties"フィールドの"property instance name"の値は、プロパティのアクセスモードです。成功した一致の条件は、"property instance name"の値が対応するMIoT-Spec-V2プロパティインスタンスのアクセスモードのサブセットであることです。
MIoT-Spec-V2サービスインスタンスがすべての必須プロパティ、イベント、アクションを含まない場合、Home Assistantエンティティは作成されません。
- プロパティ
変換は`SPEC_PROP_TRANS_MAP`に従います。
```
{
'entities':{
'<entity name>':{
'format': set<str>,
'access': set<str>
}
},
'properties': {
'<property instance name>':{
'device_class': str,
'entity': str
}
}
}
```
"entity name"の下の"format"フィールドは、プロパティのデータ形式を表し、1つの値と一致することが成功した一致を示します。"entity name"の下の"access"フィールドは、プロパティのアクセスモードを表し、すべての値と一致することが成功した一致を示します。
"property instance name"の下の"entity"フィールドの値は、"entities"フィールドの"entity name"の1つであり、作成されるHome Assistantエンティティを示します。"property instance name"の下の"device_class"フィールドは、作成されるHome Assistantエンティティの`_attr_device_class`を示します。
- イベント
変換は`SPEC_EVENT_TRANS_MAP`に従います。
```
{
'<event instance name>': str
}
```
イベントインスタンス名の値は、作成されるHome Assistantエンティティの`_attr_device_class`を示します。
### MIoT-Spec-V2フィルタ
`spec_filter.json`は、Home Assistantエンティティに変換されないMIoT-Spec-V2インスタンスをフィルタリングするために使用されます。
`spec_filter.json`の形式は次のとおりです。
```
{
"<MIoT-Spec-V2 device instance>":{
"services": list<service_iid: str>,
"properties": list<service_iid.property_iid: str>,
"events": list<service_iid.event_iid: str>,
"actions": list<service_iid.action_iid: str>,
}
}
```
`spec_filter.json`辞書のキーは、MIoT-Spec-V2デバイスインスタンスのURN"version"フィールドを除くです。同じ製品の異なるバージョンのファームウェアは、異なるバージョンのMIoT-Spec-V2デバイスインスタンスに関連付けられる場合があります。MIoTプラットフォームでは、ベンダーが製品のMIoT-Spec-V2を定義する際に、高バージョンのMIoT-Spec-V2インスタンスが低バージョンのMIoT-Spec-V2インスタンスをすべて含む必要があります。そのため、`spec_filter.json`のキーはMIoT-Spec-V2デバイスインスタンスのバージョン番号を指定する必要はありません。
デバイスインスタンスの下の"services"、"properties"、"events"、"actions"フィールドの値は、変換プロセスで無視されるサービス、プロパティ、イベント、アクションのインスタンスIDiidです。ワイルドカードマッチングがサポートされています。
例:
```
{
"urn:miot-spec-v2:device:television:0000A010:xiaomi-rmi1":{
"services": ["*"] # すべてのサービスをフィルタリングします。これは、そのようなMIoT-Spec-V2デバイスインスタンスを完全に無視することと同等です。
},
"urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1": {
"services": ["3"], # iid=3のサービスをフィルタリングします。
"properties": ["4.*"] # iid=4のサービス内のすべてのプロパティをフィルタリングします。
"events": ["4.1"], # iid=4のサービス内のiid=1のイベントをフィルタリングします。
"actions": ["4.1"] # iid=4のサービス内のiid=1のアクションをフィルタリングします。
}
}
```
すべてのデバイスのデバイス情報サービスurn:miot-spec-v2:service:device-information:00007801は、Home Assistantエンティティに変換されません。
## 多言語サポート
Xiaomi Homeの設定フロー言語オプションで選択可能な言語は、簡体字中国語、繁体字中国語、英語、スペイン語、ロシア語、フランス語、ドイツ語、日本語の8つの言語です。設定フローページの簡体字中国語と英語は開発者によって手動でレビューされています。他の言語は機械翻訳によって翻訳されています。設定フローページの単語や文を変更したい場合は、`custom_components/xiaomi_home/translations/`および`custom_components/xiaomi_home/miot/i18n/`ディレクトリ内の該当する言語のjsonファイルを変更する必要があります。
Home Assistantエンティティ名を表示する際、Xiaomi HomeはデバイスベンダーがMIoT Cloudからダウンロードした多言語ファイルを使用します。このファイルには、デバイスのMIoT-Spec-V2インスタンスの翻訳が含まれています。`multi_lang.json`はローカルで管理されている多言語辞書であり、クラウドから取得した多言語ファイルよりも優先され、デバイスの翻訳を補完または修正するために使用できます。
`multi_lang.json`の形式は次のとおりです。
```
{
"<MIoT-Spec-V2 device instance>": {
"<language code>": {
"<instance code>": <translation: str>
}
}
}
```
`multi_lang.json`辞書のキーは、MIoT-Spec-V2デバイスインスタンスのURN"version"フィールドを除く)です。
言語コードは、zh-Hans、zh-Hant、en、es、ru、fr、de、jaのいずれかであり、上記の選択可能な8つの言語に対応しています。
インスタンスコードは、MIoT-Spec-V2インスタンスのコードであり、次の形式です
```
service:<siid> # サービス
service:<siid>:property:<piid> # プロパティ
service:<siid>:property:<piid>:valuelist:<value> # プロパティの値リストの値
service:<siid>:event:<eiid> # イベント
service:<siid>:action:<aiid> # アクション
```
siid、piid、eiid、aiid、およびvalueはすべて10進数の3桁の整数です。
例:
```
{
"urn:miot-spec-v2:device:health-pot:0000A051:chunmi-a1": {
"zh-Hant": {
"service:002": "養生壺",
"service:002:property:001": "工作狀態",
"service:002:property:001:valuelist:000": "待機中",
"service:002:action:002": "停止烹飪",
"service:005:event:001": "烹飪完成"
}
}
}
```
> Home Assistantで`custom_components/xiaomi_home/miot/specs`ディレクトリ内の`specv2entity.py`、`spec_filter.json`、`multi_lang.json`ファイルの内容を編集した場合、統合の設定ページでエンティティ変換ルールを更新する必要があります。方法:[設定 > デバイスとサービス > 設定済み > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 設定 > エンティティ変換ルールの更新
## ドキュメント
- [ライセンス](../LICENSE.md)
- 貢献ガイドライン:[English](../CONTRIBUTING.md) | [简体中文](./CONTRIBUTING_zh.md)
- [変更履歴](./CHANGELOG.md)
- 開発ドキュメントhttps://developers.home-assistant.io/docs/creating_component_index
## ディレクトリ構造
- miotコアコード。
- miot/miot_client統合にユーザーを追加するには、miot_clientインスタンスを追加する必要があります。
- miot/miot_cloudクラウドサービスに関連する機能を含みます。OAuthログインプロセス、HTTPインターフェース機能ユーザー情報の取得、デバイス制御コマンドの送信など
- miot/miot_deviceデバイスエンティティ。デバイス情報、プロパティ、イベント、アクションの処理ロジックを含みます。
- miot/miot_mipsメッセージバス。メソッドの購読と公開のためのものです。
- miot/miot_specMIoT-Spec-V2を解析します。
- miot/miot_lanデバイスLANコントロール。デバイスの発見、デバイスの制御などを含みます。
- miot/miot_mdns中央ハブゲートウェイサービスのLAN発見。
- miot/miot_networkネットワーク状態とネットワーク情報の取得。
- miot/miot_storage統合のファイルストレージ。
- miot/testテストスクリプト。
- config_flow設定フロー。

View File

@ -1,6 +1,6 @@
# Home Assistant 米家集成 # Home Assistant 米家集成
[English](../README.md) | [简体中文](./README_zh.md) [English](../README.md) | [简体中文](./README_zh.md) | [日本語](./README_ja.md)
米家集成是一个由小米官方提供支持的 Home Assistant 的集成组件,它可以让您在 Home Assistant 中使用小米 IoT 智能设备。 米家集成是一个由小米官方提供支持的 Home Assistant 的集成组件,它可以让您在 Home Assistant 中使用小米 IoT 智能设备。