Skip to content

Commit 0e98669

Browse files
author
Thomas Heinz
committed
Auto-set tilt to -75° on open_cover and fix HA tilt mapping
1 parent 4f493cc commit 0e98669

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • custom_components/warema_wms_webcontrol

custom_components/warema_wms_webcontrol/cover.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def current_cover_position(self):
9898
@property
9999
def current_cover_tilt_position(self):
100100
if self.shade.tilt is not None:
101-
return round(self.shade.tilt * 100 / 255)
101+
# Map Warema angle (-90 to +90) to HA tilt (0 to 100)
102+
return round((self.shade.tilt + 90) * 100 / 180)
102103
return None
103104

104105
@property
@@ -117,7 +118,8 @@ def is_closed(self):
117118

118119
def open_cover(self, **kwargs):
119120
self.force_update_until = datetime.now() + timedelta(seconds=15)
120-
self.shade.set_shade_position(0, self.shade.tilt)
121+
tilt = -75 if self.shade.tilt is not None else None
122+
self.shade.set_shade_position(0, tilt)
121123

122124
def close_cover(self, **kwargs):
123125
self.force_update_until = datetime.now() + timedelta(seconds=15)
@@ -132,5 +134,6 @@ def set_cover_tilt_position(self, **kwargs):
132134
tilt = kwargs.get(ATTR_TILT_POSITION)
133135
if tilt is not None:
134136
self.force_update_until = datetime.now() + timedelta(seconds=15)
135-
tilt_val = round(tilt * 255 / 100)
137+
# Map HA tilt (0 to 100) back to Warema angle (-90 to +90)
138+
tilt_val = round((tilt * 180 / 100) - 90)
136139
self.shade.set_shade_position(self.shade.position, tilt_val)

0 commit comments

Comments
 (0)