From 0e7ad51439c9175b94a50eaca0dd790d69382bed Mon Sep 17 00:00:00 2001 From: Alberto Geniola Date: Sat, 28 Dec 2019 19:22:08 +0100 Subject: [PATCH] Fixed error occurring when DeviceOnline event was fired on GarageOpeners --- custom_components/meross_cloud/cover.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/meross_cloud/cover.py b/custom_components/meross_cloud/cover.py index efe55695f7..71697a2ea4 100644 --- a/custom_components/meross_cloud/cover.py +++ b/custom_components/meross_cloud/cover.py @@ -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) @@ -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)