Skip to content

Commit

Permalink
Fixed error occurring when DeviceOnline event was fired on GarageOpeners
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogeniola committed Dec 28, 2019
1 parent 967004b commit 0e7ad51
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions custom_components/meross_cloud/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from homeassistant.const import (STATE_CLOSED, STATE_CLOSING, STATE_OPEN,
STATE_OPENING, STATE_UNKNOWN)
from meross_iot.cloud.devices.door_openers import GenericGarageDoorOpener
from meross_iot.meross_event import MerossEventType

from .common import (DOMAIN, ENROLLED_DEVICES, MANAGER,
calculate_gerage_door_opener_id)
Expand Down Expand Up @@ -32,12 +33,13 @@ def __init__(self, device: GenericGarageDoorOpener, channel: int):
self._state = STATE_CLOSED

def handler(self, evt) -> None:
if evt.channel == self._channel:
# The underlying library only exposes "open" and "closed" statuses
if evt.door_state == 'open':
self._state = STATE_OPEN
elif evt.door_state == 'closed':
self._state = STATE_CLOSED
if evt.type == MerossEventType.GARAGE_DOOR_STATUS:
if evt.channel == self._channel:
# The underlying library only exposes "open" and "closed" statuses
if evt.door_state == 'open':
self._state = STATE_OPEN
elif evt.door_state == 'closed':
self._state = STATE_CLOSED

# In cny case update the UI
self.async_schedule_update_ha_state(False)
Expand Down

0 comments on commit 0e7ad51

Please sign in to comment.