Skip to content

Commit d2a1fee

Browse files
committed
Rollback username and password to constructor
1 parent 812ce78 commit d2a1fee

File tree

3 files changed

+48
-25
lines changed

3 files changed

+48
-25
lines changed

pyoverkiz/clients/overkiz.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ async def refresh_listener(invocation: Mapping[str, Any]) -> None:
6262
class OverkizClient(ABC):
6363
"""Abstract class for the Overkiz API"""
6464

65-
# username: str
66-
# password: str = field(repr=lambda _: "***")
65+
username: str
66+
password: str = field(repr=lambda _: "***")
6767
name: str
6868
endpoint: str
6969
manufacturer: str
@@ -74,9 +74,6 @@ class OverkizClient(ABC):
7474
devices: list[Device] = field(factory=list, init=False)
7575
gateways: list[Gateway] = field(factory=list, init=False)
7676

77-
# TODO: Add support for registering event listener
78-
#
79-
8077
@abstractmethod
8178
async def _login(
8279
self,
@@ -85,14 +82,12 @@ async def _login(
8582
) -> bool:
8683
"""Login to the server."""
8784

88-
async def login(
89-
self, username: str, password: str, register_event_listener: bool = True
90-
) -> bool:
85+
async def login(self, register_event_listener: bool = True) -> bool:
9186
"""
9287
Authenticate and create an API session allowing access to the other operations.
9388
Caller must provide one of [userId+userPassword, userId+ssoToken, accessToken, jwt]
9489
"""
95-
if await self._login(username, password):
90+
if await self._login(self.username, self.password):
9691
if register_event_listener:
9792
await self.register_event_listener()
9893
return False

pyoverkiz/const.py

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,103 +10,131 @@
1010
from pyoverkiz.clients.overkiz import OverkizClient
1111
from pyoverkiz.clients.somfy import SomfyClient
1212

13-
SUPPORTED_SERVERS: dict[str, Callable[[ClientSession], OverkizClient]] = {
14-
"atlantic_cozytouch": lambda session: AtlanticCozytouchClient(
13+
SUPPORTED_SERVERS: dict[str, Callable[[str, str, ClientSession], OverkizClient]] = {
14+
"atlantic_cozytouch": lambda username, password, session: AtlanticCozytouchClient(
1515
name="Atlantic Cozytouch",
1616
endpoint="https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/",
1717
manufacturer="Atlantic",
1818
configuration_url=None,
1919
session=session,
20+
username=username,
21+
password=password,
2022
),
21-
"brandt": lambda session: DefaultClient(
23+
"brandt": lambda username, password, session: DefaultClient(
2224
name="Brandt Smart Control",
2325
endpoint="https://ha3-1.overkiz.com/enduser-mobile-web/enduserAPI/",
2426
manufacturer="Brandt",
2527
configuration_url=None,
2628
session=session,
29+
username=username,
30+
password=password,
2731
),
28-
"flexom": lambda session: DefaultClient(
32+
"flexom": lambda username, password, session: DefaultClient(
2933
name="Flexom",
3034
endpoint="https://ha108-1.overkiz.com/enduser-mobile-web/enduserAPI/",
3135
manufacturer="Bouygues",
3236
configuration_url=None,
3337
session=session,
38+
username=username,
39+
password=password,
3440
),
35-
"hexaom_hexaconnect": lambda session: DefaultClient(
41+
"hexaom_hexaconnect": lambda username, password, session: DefaultClient(
3642
name="Hexaom HexaConnect",
3743
endpoint="https://ha5-1.overkiz.com/enduser-mobile-web/enduserAPI/",
3844
manufacturer="Hexaom",
3945
configuration_url=None,
4046
session=session,
47+
username=username,
48+
password=password,
4149
),
42-
"hi_kumo_asia": lambda session: DefaultClient(
50+
"hi_kumo_asia": lambda username, password, session: DefaultClient(
4351
name="Hitachi Hi Kumo (Asia)",
4452
endpoint="https://ha203-1.overkiz.com/enduser-mobile-web/enduserAPI/",
4553
manufacturer="Hitachi",
4654
configuration_url=None,
4755
session=session,
56+
username=username,
57+
password=password,
4858
),
49-
"hi_kumo_europe": lambda session: DefaultClient(
59+
"hi_kumo_europe": lambda username, password, session: DefaultClient(
5060
name="Hitachi Hi Kumo (Europe)",
5161
endpoint="https://ha117-1.overkiz.com/enduser-mobile-web/enduserAPI/",
5262
manufacturer="Hitachi",
5363
configuration_url=None,
5464
session=session,
65+
username=username,
66+
password=password,
5567
),
56-
"hi_kumo_oceania": lambda session: DefaultClient(
68+
"hi_kumo_oceania": lambda username, password, session: DefaultClient(
5769
name="Hitachi Hi Kumo (Oceania)",
5870
endpoint="https://ha203-1.overkiz.com/enduser-mobile-web/enduserAPI/",
5971
manufacturer="Hitachi",
6072
configuration_url=None,
6173
session=session,
74+
username=username,
75+
password=password,
6276
),
63-
"nexity": lambda session: NexityClient(
77+
"nexity": lambda username, password, session: NexityClient(
6478
name="Nexity Eugénie",
6579
endpoint="https://ha106-1.overkiz.com/enduser-mobile-web/enduserAPI/",
6680
manufacturer="Nexity",
6781
configuration_url=None,
6882
session=session,
83+
username=username,
84+
password=password,
6985
),
70-
"rexel": lambda session: DefaultClient(
86+
"rexel": lambda username, password, session: DefaultClient(
7187
name="Rexel Energeasy Connect",
7288
endpoint="https://ha112-1.overkiz.com/enduser-mobile-web/enduserAPI/",
7389
manufacturer="Rexel",
7490
configuration_url="https://utilisateur.energeasyconnect.com/user/#/zone/equipements",
7591
session=session,
92+
username=username,
93+
password=password,
7694
),
77-
"simu_livein2": lambda session: DefaultClient( # alias of https://tahomalink.com
95+
"simu_livein2": lambda username, password, session: DefaultClient( # alias of https://tahomalink.com
7896
name="SIMU (LiveIn2)",
7997
endpoint="https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/",
8098
manufacturer="Somfy",
8199
configuration_url=None,
82100
session=session,
101+
username=username,
102+
password=password,
83103
),
84-
"somfy_europe": lambda session: SomfyClient( # alias of https://tahomalink.com
104+
"somfy_europe": lambda username, password, session: SomfyClient( # alias of https://tahomalink.com
85105
name="Somfy (Europe)",
86106
endpoint="https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/",
87107
manufacturer="Somfy",
88108
configuration_url="https://www.tahomalink.com",
89109
session=session,
110+
username=username,
111+
password=password,
90112
),
91-
"somfy_america": lambda session: DefaultClient(
113+
"somfy_america": lambda username, password, session: DefaultClient(
92114
name="Somfy (North America)",
93115
endpoint="https://ha401-1.overkiz.com/enduser-mobile-web/enduserAPI/",
94116
manufacturer="Somfy",
95117
configuration_url=None,
96118
session=session,
119+
username=username,
120+
password=password,
97121
),
98-
"somfy_oceania": lambda session: DefaultClient(
122+
"somfy_oceania": lambda username, password, session: DefaultClient(
99123
name="Somfy (Oceania)",
100124
endpoint="https://ha201-1.overkiz.com/enduser-mobile-web/enduserAPI/",
101125
manufacturer="Somfy",
102126
configuration_url=None,
103127
session=session,
128+
username=username,
129+
password=password,
104130
),
105-
"ubiwizz": lambda session: DefaultClient(
131+
"ubiwizz": lambda username, password, session: DefaultClient(
106132
name="Ubiwizz",
107133
endpoint="https://ha129-1.overkiz.com/enduser-mobile-web/enduserAPI/",
108134
manufacturer="Decelect",
109135
configuration_url=None,
110136
session=session,
137+
username=username,
138+
password=password,
111139
),
112140
}

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class TestOverkizClient:
1616
@fixture
1717
def client(self):
18-
return SUPPORTED_SERVERS["somfy_europe"](aiohttp.ClientSession())
18+
return SUPPORTED_SERVERS["somfy_europe"]("foo", "pass", aiohttp.ClientSession())
1919

2020
@pytest.mark.asyncio
2121
async def test_get_devices_basic(self, client):

0 commit comments

Comments
 (0)