Compare commits

...

6 Commits

Author SHA1 Message Date
ohyeah521
73ab8fa9f7
Merge 1258d3f3d3 into 75390a3d83 2025-12-23 14:52:29 +08:00
Li Shuzhen
75390a3d83
docs: update changelog and version to v0.4.6 (#1565)
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-12-18 09:37:27 +08:00
Li Shuzhen
86a739b503
feat: add tv-box device as media player entity (#1562) 2025-12-18 09:04:59 +08:00
ohyeah521
1258d3f3d3
Merge branch 'XiaoMi:main' into main 2025-09-10 14:05:45 +08:00
ohyeah521
64d9d54170
Merge branch 'XiaoMi:main' into main 2025-08-24 10:12:48 -04:00
ohyeah521
059eee33e0
Fix #1309 #1124
# HomeKit Bridge: fan_modes must be "auto"、"low"、"medium"、"high"
2025-07-28 23:23:21 +08:00
5 changed files with 121 additions and 21 deletions

View File

@ -1,4 +1,19 @@
# CHANGELOG
## v0.4.6
### Added
- Add tv-box device as the media player entity. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
- Set play-control service's play-loop-mode property as the sound mode. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
### Changed
- Use constant value to indicate the cloud MQTT broker host domain. [#1530](https://github.com/XiaoMi/ha_xiaomi_home/pull/1530)
- Use constant value to indicate the timer delay of refreshing devices. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
- Set the playing-state property as the required property in the play-control service of the speaker device. [#1552](https://github.com/XiaoMi/ha_xiaomi_home/pull/1552)
- Set the playing-state property as the required property in the optional play-control service of the television. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
### Fixed
- 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)
- 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)
## v0.4.5
### Changed
- Ignore mdns REMOVED package. [#1296](https://github.com/XiaoMi/ha_xiaomi_home/pull/1296)

View File

@ -224,6 +224,15 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
_prop_fan_level: Optional[MIoTSpecProperty]
_fan_mode_map: Optional[dict[int, str]]
# HomeKit Bridge: fan_modes must be "auto"、"low"、"medium"、"high"
_fan_mode_translation_map = {
"自动": "auto",
"低风": "low",
"中风": "medium",
"高风": "high",
}
_fan_mode_translation_map_rev = {v: k for k, v in _fan_mode_translation_map.items()}
def __init__(self, miot_device: MIoTDevice,
entity_data: MIoTEntityData) -> None:
"""Initialize the feature class."""
@ -243,7 +252,13 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
self.entity_id)
continue
self._fan_mode_map = prop.value_list.to_map()
self._attr_fan_modes = prop.value_list.descriptions
# save org fan speed
self._raw_fan_modes = prop.value_list.descriptions
self._attr_fan_modes = [
self._fan_mode_translation_map.get(mode, mode)
for mode in self._raw_fan_modes
]
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
self._prop_fan_level = prop
elif prop.name == 'on' and prop.service.name == 'fan-control':
@ -264,7 +279,11 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
if fan_mode == FAN_ON:
await self.set_property_async(prop=self._prop_fan_on, value=True)
return
mode_value = self.get_map_key(map_=self._fan_mode_map, value=fan_mode)
chinese_fan_mode = self._fan_mode_translation_map_rev.get(fan_mode, fan_mode)
mode_value = self.get_map_key(map_=self._fan_mode_map, value=chinese_fan_mode)
if mode_value is None or not await self.set_property_async(
prop=self._prop_fan_level, value=mode_value):
raise RuntimeError(f'set climate prop.fan_mode failed, {fan_mode}, '
@ -278,9 +297,15 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
if self._prop_fan_level is None and self._prop_fan_on:
return (FAN_ON if self.get_prop_value(
prop=self._prop_fan_on) else FAN_OFF)
return self.get_map_value(
current_chinese_mode = self.get_map_value(
map_=self._fan_mode_map,
key=self.get_prop_value(prop=self._prop_fan_level))
if current_chinese_mode is None:
return None
return self._fan_mode_translation_map.get(current_chinese_mode, current_chinese_mode)
class FeatureSwingMode(MIoTServiceEntity, ClimateEntity):

View File

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

View File

@ -436,7 +436,8 @@ class MIoTDevice:
optional_properties: dict
required_actions: set
optional_actions: set
# 2. The service shall have all required properties, actions.
# 2. The required service shall have all required properties
# and actions.
if service.name in required_services:
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
'required'].get(
@ -454,6 +455,23 @@ class MIoTDevice:
'required'].get(
service.name, {}
).get('optional', {}).get('actions', set({}))
if not {
prop.name for prop in service.properties if prop.access
}.issuperset(set(required_properties.keys())):
return None
if not {
action.name for action in service.actions
}.issuperset(required_actions):
return None
# 3. The required property in required service shall have all
# required access mode.
for prop in service.properties:
if prop.name in required_properties:
if not set(prop.access).issuperset(
required_properties[prop.name]):
return None
# 4. The optional service shall have all required properties
# and actions.
elif service.name in optional_services:
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
'optional'].get(
@ -471,22 +489,23 @@ class MIoTDevice:
'optional'].get(
service.name, {}
).get('optional', {}).get('actions', set({}))
if not {
prop.name for prop in service.properties if prop.access
}.issuperset(set(required_properties.keys())):
continue
if not {
action.name for action in service.actions
}.issuperset(required_actions):
continue
# 5. The required property in optional service shall have all
# required access mode.
for prop in service.properties:
if prop.name in required_properties:
if not set(prop.access).issuperset(
required_properties[prop.name]):
continue
else:
continue
if not {
prop.name for prop in service.properties if prop.access
}.issuperset(set(required_properties.keys())):
return None
if not {
action.name for action in service.actions
}.issuperset(required_actions):
return None
# 3. The required property shall have all required access mode.
for prop in service.properties:
if prop.name in required_properties:
if not set(prop.access).issuperset(
required_properties[prop.name]):
return None
# property
for prop in service.properties:
if prop.name in set.union(

View File

@ -331,6 +331,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
'actions': {'play'}
},
'optional': {
'properties': {'play-loop-mode'},
'actions': {'pause', 'stop', 'next', 'previous'}
}
}
@ -362,9 +363,49 @@ SPEC_DEVICE_TRANS_MAP: dict = {
},
'optional': {
'play-control': {
'required': {},
'required': {
'properties': {
'playing-state': {'read'}
}
},
'optional': {
'properties': {'playing-state'},
'properties': {'play-loop-mode'},
'actions': {'play', 'pause', 'stop', 'next', 'previous'}
}
}
},
'entity': 'television'
},
'tv-box':{
'required': {
'speaker': {
'required': {
'properties': {
'volume': {'read', 'write'}
}
},
'optional': {
'properties': {'mute'}
}
},
'tv-box': {
'required': {
'actions': {'turn-off'}
},
'optional': {
'actions': {'turn-on'}
}
}
},
'optional': {
'play-control': {
'required': {
'properties': {
'playing-state': {'read'}
}
},
'optional': {
'properties': {'play-loop-mode'},
'actions': {'play', 'pause', 'stop', 'next', 'previous'}
}
}