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 1acec4e commit 335e35a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@
},

'uvfive.steriliser.maine': CHUNK_1,

'viomi.airer.xy108': {
'switch_properties': 'dryer',
},
Expand Down
4 changes: 4 additions & 0 deletions 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
_cover_position_mapping = None
_target2current_position = None

def on_init(self):
Expand Down Expand Up @@ -96,6 +97,7 @@ 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 Expand Up @@ -124,6 +126,8 @@ def set_state(self, data: dict):
val = self._conv_current_position.value_from_dict(data)
if val is not None:
val = int(val)
if self._cover_position_mapping:
val = self._cover_position_mapping.get(val, val)
if self._position_reverse:
val = self._current_range[1] - val
self._attr_current_cover_position = val
Expand Down

0 comments on commit 335e35a

Please sign in to comment.