Skip to content

Commit 2eaa07c

Browse files
starkillerOGabmantis
authored andcommitted
Reverse Motion Blinds tilt direction (home-assistant#149777)
Co-authored-by: Abílio Costa <[email protected]>
1 parent ef52ec3 commit 2eaa07c

File tree

1 file changed

+22
-14
lines changed
  • homeassistant/components/motion_blinds

1 file changed

+22
-14
lines changed

homeassistant/components/motion_blinds/cover.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class MotionBaseDevice(MotionCoordinatorEntity, CoverEntity):
174174

175175
_restore_tilt = False
176176

177-
def __init__(self, coordinator, blind, device_class):
177+
def __init__(self, coordinator, blind, device_class) -> None:
178178
"""Initialize the blind."""
179179
super().__init__(coordinator, blind)
180180

@@ -275,7 +275,7 @@ def current_cover_tilt_position(self) -> int | None:
275275
"""
276276
if self._blind.angle is None:
277277
return None
278-
return self._blind.angle * 100 / 180
278+
return 100 - (self._blind.angle * 100 / 180)
279279

280280
@property
281281
def is_closed(self) -> bool | None:
@@ -287,22 +287,22 @@ def is_closed(self) -> bool | None:
287287
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
288288
"""Open the cover tilt."""
289289
async with self._api_lock:
290-
await self.hass.async_add_executor_job(self._blind.Set_angle, 180)
290+
await self.hass.async_add_executor_job(self._blind.Set_angle, 0)
291291

292292
await self.async_request_position_till_stop()
293293

294294
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
295295
"""Close the cover tilt."""
296296
async with self._api_lock:
297-
await self.hass.async_add_executor_job(self._blind.Set_angle, 0)
297+
await self.hass.async_add_executor_job(self._blind.Set_angle, 180)
298298

299299
await self.async_request_position_till_stop()
300300

301301
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
302302
"""Move the cover tilt to a specific position."""
303303
angle = kwargs[ATTR_TILT_POSITION] * 180 / 100
304304
async with self._api_lock:
305-
await self.hass.async_add_executor_job(self._blind.Set_angle, angle)
305+
await self.hass.async_add_executor_job(self._blind.Set_angle, 180 - angle)
306306

307307
await self.async_request_position_till_stop()
308308

@@ -347,19 +347,19 @@ def current_cover_tilt_position(self) -> int | None:
347347
if self._blind.position is None:
348348
if self._blind.angle is None:
349349
return None
350-
return self._blind.angle * 100 / 180
350+
return 100 - (self._blind.angle * 100 / 180)
351351

352-
return self._blind.position
352+
return 100 - self._blind.position
353353

354354
@property
355355
def is_closed(self) -> bool | None:
356356
"""Return if the cover is closed or not."""
357357
if self._blind.position is None:
358358
if self._blind.angle is None:
359359
return None
360-
return self._blind.angle == 0
360+
return self._blind.angle == 180
361361

362-
return self._blind.position == 0
362+
return self._blind.position == 100
363363

364364
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
365365
"""Open the cover tilt."""
@@ -381,10 +381,14 @@ async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
381381
if self._blind.position is None:
382382
angle = angle * 180 / 100
383383
async with self._api_lock:
384-
await self.hass.async_add_executor_job(self._blind.Set_angle, angle)
384+
await self.hass.async_add_executor_job(
385+
self._blind.Set_angle, 180 - angle
386+
)
385387
else:
386388
async with self._api_lock:
387-
await self.hass.async_add_executor_job(self._blind.Set_position, angle)
389+
await self.hass.async_add_executor_job(
390+
self._blind.Set_position, 100 - angle
391+
)
388392

389393
await self.async_request_position_till_stop()
390394

@@ -397,18 +401,22 @@ async def async_set_absolute_position(self, **kwargs):
397401
if self._blind.position is None:
398402
angle = angle * 180 / 100
399403
async with self._api_lock:
400-
await self.hass.async_add_executor_job(self._blind.Set_angle, angle)
404+
await self.hass.async_add_executor_job(
405+
self._blind.Set_angle, 180 - angle
406+
)
401407
else:
402408
async with self._api_lock:
403-
await self.hass.async_add_executor_job(self._blind.Set_position, angle)
409+
await self.hass.async_add_executor_job(
410+
self._blind.Set_position, 100 - angle
411+
)
404412

405413
await self.async_request_position_till_stop()
406414

407415

408416
class MotionTDBUDevice(MotionBaseDevice):
409417
"""Representation of a Motion Top Down Bottom Up blind Device."""
410418

411-
def __init__(self, coordinator, blind, device_class, motor):
419+
def __init__(self, coordinator, blind, device_class, motor) -> None:
412420
"""Initialize the blind."""
413421
super().__init__(coordinator, blind, device_class)
414422
self._motor = motor

0 commit comments

Comments
 (0)