Skip to content

Commit

Permalink
🔧 fix for cover_position_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Feb 8, 2025
1 parent 335e35a commit 528fcf2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/xiaomi_miot/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,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._cover_position_mapping = self.custom_config_json('cover_position_mapping') or {}

for conv in self.device.converters:
prop = getattr(conv, 'prop', None)
Expand All @@ -86,8 +87,12 @@ def on_init(self):
if prop.list_first('Stop', 'Pause') != None:
self._attr_supported_features |= CoverEntityFeature.STOP
elif prop.value_range and prop.in_list(['current_position']):
self._conv_current_position = conv
self._current_range = (prop.range_min(), prop.range_max())
if prop.value_range:
self._conv_current_position = conv
self._current_range = (prop.range_min(), prop.range_max())
elif prop.value_list and self._cover_position_mapping:
self._conv_current_position = conv
self._current_range = (0, 100)
elif prop.value_range and isinstance(conv, MiotTargetPositionConv):
self._conv_target_position = conv
self._target_range = conv.ranged
Expand All @@ -97,7 +102,6 @@ def on_init(self):
self._target_range = (prop.range_min(), prop.range_max())
self._attr_supported_features |= CoverEntityFeature.SET_POSITION

self._cover_position_mapping = self.custom_config_json('cover_position_mapping') or {}
self._deviated_position = self.custom_config_integer('deviated_position', 2)
if self._current_range:
pos = self._current_range[0] + self._deviated_position
Expand Down

0 comments on commit 528fcf2

Please sign in to comment.