Skip to content

Commit

Permalink
👔 fix for hyd.airer.pro2 (#2327)
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Feb 11, 2025
1 parent 57447d8 commit 543b9c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions custom_components/xiaomi_miot/core/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@ def add_converter(self, conv: BaseConv):
return
self.converters.append(conv)

def add_converter_by_property(self, prop: MiotProperty, domain=None, option=None, cls=None, **kwargs):
if not cls:
cls = MiotPropConv
conv = cls(prop.full_name, domain=domain, prop=prop, **kwargs)
if option:
conv.with_option(**option)
self.add_converter(conv)
return conv

def find_converter(self, full_name):
for c in self.converters:
if c.full_name == full_name:
Expand Down
8 changes: 5 additions & 3 deletions custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,19 +756,21 @@
'append_converters': [
{
'services': ['set_night_light'],
'converters': [{'props': ['current_position']}],
'converters': [{'props': ['current_position', 'set_position']}],
}
],
'target_position_props': 'set_position',
'cover_position_mapping': None,
},
'hyd.airer.pro2': {
'append_converters': [
{
'services': ['set_night_light'],
'converters': [{'props': ['current_position']}],
'converters': [{'props': ['current_position', 'set_position']}],
}
],
'cover_position_mapping': None
'target_position_props': 'set_position',
'cover_position_mapping': None,
},
'hyd.airer.znlyj5': {
'cover_position_mapping': {0: 50, 1: 0, 2: 100},
Expand Down
4 changes: 3 additions & 1 deletion custom_components/xiaomi_miot/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CoverEntity(XEntity, BaseEntity):
_close_texts = ['close', 'down']
_closed_position = 0
_deviated_position = 0
_target_position_props = None
_cover_position_mapping = None
_target2current_position = None

Expand All @@ -72,6 +73,7 @@ def on_init(self):
self._close_texts = self.custom_config_list('close_texts', self._close_texts)
if self._motor_reverse:
self._open_texts, self._close_texts = self._close_texts, self._open_texts
self._target_position_props = self.custom_config_list('target_position_props') or ['target_position']
self._cover_position_mapping = self.custom_config_json('cover_position_mapping') or {}

for conv in self.device.converters:
Expand All @@ -97,7 +99,7 @@ def on_init(self):
self._conv_target_position = conv
self._target_range = conv.ranged
self._attr_supported_features |= CoverEntityFeature.SET_POSITION
elif prop.value_range and prop.in_list(['target_position']):
elif prop.value_range and prop.in_list(self._target_position_props):
self._conv_target_position = conv
self._target_range = (prop.range_min(), prop.range_max())
self._attr_supported_features |= CoverEntityFeature.SET_POSITION
Expand Down

0 comments on commit 543b9c6

Please sign in to comment.