Skip to content

Commit

Permalink
add possibility to set callback after the constructor following revie…
Browse files Browse the repository at this point in the history
…w of homeassistant integration
  • Loading branch information
cnico committed Jun 25, 2024
1 parent 275455e commit 5579fdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dio-chacon-wifi-api"
version = "1.0.1"
version = "1.0.2"
description = "Python library for DIO Chacon wifi's protocol for shutters and switches"
authors = ["cnico"]
license = "GNU Lesser General Public License v3 or later (LGPLv3+)"
Expand Down
3 changes: 3 additions & 0 deletions src/dio_chacon_wifi_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def __init__(
self._auth_url: str = DIOCHACON_AUTH_URL
self._ws_url: str = DIOCHACON_WS_URL

def set_callback_device_state(self, callback_device_state: callable) -> None:
self._callback_device_state = callback_device_state

def _set_server_urls(self, auth_url: str, ws_url: str) -> None:
# Simple method to easily mock the server url.
self._auth_url = auth_url
Expand Down
3 changes: 2 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ async def test_client(aiohttp_server) -> None:

_LOGGER.debug("Launching test client...")

client = DIOChaconAPIClient(USERNAME, PASSWORD, INSTALLATION_ID, log_callback)
client = DIOChaconAPIClient(USERNAME, PASSWORD, INSTALLATION_ID)
client.set_callback_device_state(log_callback)
client._set_server_urls(f"http://localhost:{MOCK_PORT}/api/session/login", f"ws://localhost:{MOCK_PORT}/ws")

# Test get_user_id
Expand Down

0 comments on commit 5579fdf

Please sign in to comment.