Skip to content

Commit

Permalink
Elro K1 connector is not connecting to HA #17 (#22)
Browse files Browse the repository at this point in the history
* Ignore fles

* Show exception information in fire_alarm_demo
Check command result for ST_answer_OK message and continue before checking if the result is valid JSON

* Updated version

* Follow coding guideliens

Co-authored-by: Jan Bouwhuis <[email protected]>

* Remove commented line for additional logging information

Co-authored-by: Jan Bouwhuis <[email protected]>

* Exception handling in demo1

Use better naming for the exception
Remove pass if an exception is caught

---------

Co-authored-by: AmpioRosso <[email protected]>
Co-authored-by: Jan Bouwhuis <[email protected]>
  • Loading branch information
3 people authored Jul 13, 2023
1 parent 10d73ce commit a94d646
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ venv.bak/

# vscode
.vscode/*
.vs/*
2 changes: 1 addition & 1 deletion elro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Elro connects P1 API."""

__version__ = "0.5.4"
__version__ = "0.5.4.1"
5 changes: 5 additions & 0 deletions elro/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ async def async_process_command(
else None,
)
self._protocol.datagram_data = self._loop.create_future()
if (
raw_data[0].decode("utf-8").strip().casefold()
== "{ST_answer_OK}".casefold()
):
continue
data = validate_json(raw_data[0])
params = data["params"]
cmd_id = params["data"]["cmdId"]
Expand Down
4 changes: 2 additions & 2 deletions examples/fire_alarm_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ async def async_demo1(self) -> None:
print(
f"{key} ({item.get('name')}): status={item['device_state']} data={item['device_status_data']}"
)
except Exception: # pylint: disable=broad-except
pass
except Exception as err: # pylint: disable=broad-except
print(f"Exception caught {err.args}")
finally:
await asyncio.sleep(INTERVAL)

Expand Down

0 comments on commit a94d646

Please sign in to comment.