Skip to content

Commit

Permalink
Merge pull request #458 from krahabb/dev_5_2_2
Browse files Browse the repository at this point in the history
Moonlight.2.2
  • Loading branch information
krahabb authored Jun 11, 2024
2 parents 9538564 + fc56c70 commit 85a576d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
7 changes: 3 additions & 4 deletions custom_components/meross_lan/helpers/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def handle_exception(self, exception: Exception, function_name: str, payload):
self.namespace,
function_name,
str(device.loggable_any(payload)),
timeout=604800
timeout=604800,
)

def _handle_list(self, header, payload):
Expand Down Expand Up @@ -219,7 +219,7 @@ def _handle_dict(self, header, payload):
_parse = self.entities[p_channel.get(mc.KEY_CHANNEL)]
except KeyError as key_error:
_parse = self._try_create_entity(key_error)
except TypeError:
except AttributeError:
# this might be expected: the payload is not a dict
# final fallback to the safe _handle_generic
self.handler = self._handle_generic
Expand All @@ -233,7 +233,7 @@ def _handle_generic(self, header, payload):
the registered entity(es)
This handler can manage both lists or dicts or even
payloads without the "channel" key (see namespace Toggle)
which will default forwarding to channel == 0
which will default forwarding to channel == None
"""
p_channel = payload[self.key_namespace]
if type(p_channel) is dict:
Expand Down Expand Up @@ -302,7 +302,6 @@ def parse_generic(self, digest: list | dict):
except KeyError as key_error:
_parse = self._try_create_entity(key_error)
_parse(p_channel)

except Exception as exception:
self.handle_exception(exception, "_parse_generic", digest)

Expand Down
2 changes: 1 addition & 1 deletion custom_components/meross_lan/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"/appliance/+/publish"
],
"requirements": [],
"version": "5.2.1"
"version": "5.2.2"
}
12 changes: 9 additions & 3 deletions emulator/mixins/garagedoor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""""""

import asyncio
from random import randint
import typing

from custom_components.meross_lan.merossclient import (
Expand Down Expand Up @@ -51,9 +52,14 @@ def _GET_Appliance_GarageDoor_State(self, header, payload):
# return everything...at the moment we always query all
p_garageDoor: list = self.descriptor.digest[mc.KEY_GARAGEDOOR]
if len(p_garageDoor) == 1:
# un-pack the list since real traces show no list
# in this response payloads (we only have msg100 so far..)
return mc.METHOD_GETACK, {mc.KEY_STATE: p_garageDoor[0]}
# for msg100 we had, historically, just dict payloads
# in this ns but now it appears as though some devices/queries
# might return a list (#439). We'll introduce this randomness
# here to test if meross_lan is able to manage both.
if randint(0, 1) == 0:
return mc.METHOD_GETACK, {mc.KEY_STATE: p_garageDoor[0]}
else:
return mc.METHOD_GETACK, {mc.KEY_STATE: p_garageDoor}
else:
return mc.METHOD_GETACK, {mc.KEY_STATE: p_garageDoor}

Expand Down

0 comments on commit 85a576d

Please sign in to comment.