Compare commits

...

5 Commits

Author SHA1 Message Date
lifetimr
df0b0ed73a
Merge 30a78c7689 into b40d357230 2025-12-31 16:08:47 +08:00
Li Shuzhen
b40d357230
fix: update mesh offline state (#1579)
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-31 09:58:29 +08:00
lifetimr
30a78c7689
Merge pull request #1 from lifetimr/lifetimr-patch-1
Update cover.py
2025-11-25 22:10:27 +08:00
lifetimr
eec13826d2
Update cover.py 2025-11-25 22:09:41 +08:00
lifetimr
bf1caf50e1
修改cover模块下OPEN/STOP/PAUSE无法正常暴露的问题 2025-11-24 20:52:23 +08:00
2 changed files with 15 additions and 1 deletions

View File

@ -107,6 +107,7 @@ class Cover(MIoTServiceEntity, CoverEntity):
_prop_position_value_range: Optional[int]
_prop_pos_closing: bool
_prop_pos_opening: bool
_reverse_position: bool
def __init__(self, miot_device: MIoTDevice,
entity_data: MIoTEntityData) -> None:
@ -134,6 +135,8 @@ class Cover(MIoTServiceEntity, CoverEntity):
self._prop_position_value_range = None
self._prop_pos_closing = False
self._prop_pos_opening = False
# 新增针对airer类型设备反转位置
self._reverse_position = (entity_data.spec.device_class == CoverDeviceClass.BLIND)
# properties
for prop in entity_data.props:
@ -143,6 +146,8 @@ class Cover(MIoTServiceEntity, CoverEntity):
self.entity_id)
continue
for item in prop.value_list.items:
item_str: str = item.name
item_name: str = re.sub(r'[^a-z]', '', item_str)
if item.name in {'open', 'up'}:
self._attr_supported_features |= (
CoverEntityFeature.OPEN)
@ -255,6 +260,10 @@ class Cover(MIoTServiceEntity, CoverEntity):
if current is not None:
self._prop_pos_opening = pos > current
self._prop_pos_closing = pos < current
# 针对airer类型设备反转位置
if self._reverse_position:
pos = 100 - pos
pos = round(pos * self._prop_position_value_range / 100)
await self.set_property_async(prop=self._prop_target_position,
value=pos)
@ -282,6 +291,9 @@ class Cover(MIoTServiceEntity, CoverEntity):
pos = 0
elif pos >= (100 - self._cover_dead_zone_width):
pos = 100
# 针对airer类型设备反转位置
if self._reverse_position:
pos = 100 - pos
return pos
@property

View File

@ -1527,6 +1527,8 @@ class MIoTClient:
if did not in filter_dids:
continue
device_old = self._device_list_gateway.get(did, None)
gw_state_old = device_old.get(
'online', False) if device_old else False
gw_state_new: bool = False
device_new = gw_list.pop(did, None)
if device_new:
@ -1540,7 +1542,7 @@ class MIoTClient:
device_old['online'] = False
# Update cache group_id
info['group_id'] = group_id
if not gw_state_new:
if (gw_state_old == gw_state_new) and (not gw_state_new):
continue
self.__update_device_msg_sub(did=did)
state_old: Optional[bool] = info.get('online', None)