Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Updated sending commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeko12 committed Dec 30, 2022
1 parent bfea29d commit 60ff0f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='pyelectroluxconnect',
version='0.3.10',
version='0.3.11',
description='Interface for Electrolux Connectivity Platform API',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
19 changes: 17 additions & 2 deletions src/pyelectroluxconnect/Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,14 +670,27 @@ def _sendApplianceCommand(self,

components = []

containerHacl = ""
for param in params:
if(not isinstance(param, dict)):
raise Error("Parameters to send must be list of dicts")
for key in param:
if(param[key] == "Container"):
dataFormat = ""
if param[key] == "Container":
containerHacl = key
dataFormat = self._applianceProfiles[applianceId][f'{destination}:{key}']['data_format']
elif containerHacl != "":
dataFormat = self._applianceProfiles[applianceId][f'{destination}:{containerHacl}']["container"][0][key]['data_format']
else:
dataFormat = self._applianceProfiles[applianceId][f'{destination}:{key}']['data_format']

if((dataFormat == "struct" or dataFormat.startswith("array")) and param[key] == "Container"):
components.append(
{"name": key.removeprefix("0x"), "value": "Container"})
else:
elif dataFormat =="string":
components.append(
{"name": key.removeprefix("0x"), "value": param[key].removeprefix("0x")})
elif dataFormat.startswith("int") or dataFormat.startswith("uint") or dataFormat.startswith("bool"):
_intVal = 0
if(isinstance(param[key], str)
and param[key].startswith("0x")):
Expand All @@ -688,6 +701,8 @@ def _sendApplianceCommand(self,
_intVal = param[key]
components.append(
{"name": key.removeprefix("0x"), "value": _intVal})
else:
raise Error(f"Unsupported data_format {dataFormat} for {key}:{param[key]}")
if(appliance):
_payload = {
"components": components,
Expand Down

1 comment on commit 60ff0f2

@tomeko12
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#8

Please sign in to comment.