mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2025-12-22 13:22:13 +08:00
Merge branch 'main' into entity-category
This commit is contained in:
@@ -1213,10 +1213,12 @@ class MipsLocalClient(_MipsClient):
|
||||
or 'did' not in msg
|
||||
or 'siid' not in msg
|
||||
or 'eiid' not in msg
|
||||
or 'arguments' not in msg
|
||||
# or 'arguments' not in msg
|
||||
):
|
||||
# self.log_error(f'on_event_msg, recv unknown msg, {payload}')
|
||||
return
|
||||
if 'arguments' not in msg:
|
||||
msg['arguments'] = []
|
||||
if handler:
|
||||
self.log_debug('local, on event_occurred, %s', payload)
|
||||
handler(msg, ctx)
|
||||
|
||||
@@ -542,7 +542,7 @@ class MIoTSpecProperty(_MIoTSpecBase):
|
||||
self.unit = unit
|
||||
self.value_range = value_range
|
||||
self.value_list = value_list
|
||||
self.precision = precision or 1
|
||||
self.precision = precision if precision is not None else 1
|
||||
self.expr = expr
|
||||
|
||||
self.spec_id = hash(
|
||||
@@ -1200,6 +1200,20 @@ class _SpecModify:
|
||||
return None
|
||||
return access
|
||||
|
||||
def get_prop_value_range(self, siid: int, piid: int) -> Optional[list]:
|
||||
value_range = self.__get_prop_item(siid=siid, piid=piid,
|
||||
key='value-range')
|
||||
if not isinstance(value_range, list):
|
||||
return None
|
||||
return value_range
|
||||
|
||||
def get_prop_value_list(self, siid: int, piid: int) -> Optional[list]:
|
||||
value_list = self.__get_prop_item(siid=siid, piid=piid,
|
||||
key='value-list')
|
||||
if not isinstance(value_list, list):
|
||||
return None
|
||||
return value_list
|
||||
|
||||
def __get_prop_item(self, siid: int, piid: int, key: str) -> Optional[str]:
|
||||
if not self._selected:
|
||||
return None
|
||||
@@ -1476,6 +1490,14 @@ class MIoTSpecParser:
|
||||
siid=service['iid'], piid=property_['iid'])
|
||||
if custom_access:
|
||||
spec_prop.access = custom_access
|
||||
custom_range = self._spec_modify.get_prop_value_range(
|
||||
siid=service['iid'], piid=property_['iid'])
|
||||
if custom_range:
|
||||
spec_prop.value_range = custom_range
|
||||
custom_list = self._spec_modify.get_prop_value_list(
|
||||
siid=service['iid'], piid=property_['iid'])
|
||||
if custom_list:
|
||||
spec_prop.value_list = custom_list
|
||||
# Parse service event
|
||||
for event in service.get('events', []):
|
||||
if (
|
||||
|
||||
@@ -42,3 +42,19 @@ urn:miot-spec-v2:device:router:0000A036:xiaomi-rd08:1:
|
||||
name: upload-speed
|
||||
icon: mdi:upload
|
||||
unit: B/s
|
||||
urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1:
|
||||
prop.2.3:
|
||||
value-range:
|
||||
- 0
|
||||
- 1
|
||||
- 1
|
||||
urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:2: urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1
|
||||
urn:miot-spec-v2:device:bath-heater:0000A028:opple-acmoto:1:
|
||||
prop.5.2:
|
||||
value-list:
|
||||
- value: 1
|
||||
description: low
|
||||
- value: 128
|
||||
description: medium
|
||||
- value: 255
|
||||
description: high
|
||||
|
||||
@@ -225,6 +225,31 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
||||
'entity': 'air-conditioner'
|
||||
},
|
||||
'air-condition-outlet': 'air-conditioner',
|
||||
'thermostat': {
|
||||
'required': {
|
||||
'thermostat': {
|
||||
'required': {
|
||||
'properties': {
|
||||
'on': {'read', 'write'}
|
||||
}
|
||||
},
|
||||
'optional': {
|
||||
'properties': {
|
||||
'target-temperature', 'mode', 'fan-level',
|
||||
'temperature'}
|
||||
},
|
||||
}
|
||||
},
|
||||
'optional': {
|
||||
'environment': {
|
||||
'required': {},
|
||||
'optional': {
|
||||
'properties': {'temperature', 'relative-humidity'}
|
||||
}
|
||||
},
|
||||
},
|
||||
'entity': 'thermostat'
|
||||
},
|
||||
'heater': {
|
||||
'required': {
|
||||
'heater': {
|
||||
@@ -247,7 +272,48 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
||||
},
|
||||
},
|
||||
'entity': 'heater'
|
||||
}
|
||||
},
|
||||
'bath-heater': {
|
||||
'required': {
|
||||
'ptc-bath-heater': {
|
||||
'required': {},
|
||||
'optional': {
|
||||
'properties': {
|
||||
'target-temperature', 'heat-level',
|
||||
'temperature', 'mode'
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
'optional': {
|
||||
'fan-control': {
|
||||
'required': {},
|
||||
'optional': {
|
||||
'properties': {
|
||||
'on', 'fan-level', 'horizontal-swing', 'vertical-swing'
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
'entity': 'bath-heater',
|
||||
},
|
||||
'electric-blanket': {
|
||||
'required': {
|
||||
'electric-blanket': {
|
||||
'required': {
|
||||
'properties': {
|
||||
'on': {'read', 'write'},
|
||||
'target-temperature': {'read', 'write'}
|
||||
}
|
||||
},
|
||||
'optional': {
|
||||
'properties': {'mode', 'temperature'}
|
||||
},
|
||||
}
|
||||
},
|
||||
'optional': {},
|
||||
'entity': 'electric-blanket'
|
||||
},
|
||||
}
|
||||
|
||||
"""SPEC_SERVICE_TRANS_MAP
|
||||
@@ -339,7 +405,9 @@ SPEC_SERVICE_TRANS_MAP: dict = {
|
||||
},
|
||||
'entity': 'cover'
|
||||
},
|
||||
'window-opener': 'curtain'
|
||||
'window-opener': 'curtain',
|
||||
'motor-controller': 'curtain',
|
||||
'airer': 'curtain'
|
||||
}
|
||||
|
||||
"""SPEC_PROP_TRANS_MAP
|
||||
|
||||
Reference in New Issue
Block a user