Hydro-Quebec-API-Wrapper 3.2.0__py3-none-any.whl → 4.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info}/METADATA +9 -8
- hydro_quebec_api_wrapper-4.1.0.dist-info/RECORD +53 -0
- {Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info}/WHEEL +1 -1
- hydroqc/account.py +1 -0
- hydroqc/contract/common.py +25 -19
- hydroqc/contract/contract_d.py +5 -4
- hydroqc/contract/contract_d_cpc.py +8 -7
- hydroqc/contract/contract_dpc.py +9 -8
- hydroqc/contract/contract_dt.py +5 -4
- hydroqc/contract/contract_m.py +15 -14
- hydroqc/contract/contract_m_gdp.py +5 -4
- hydroqc/contract/contract_residential.py +10 -9
- hydroqc/customer.py +9 -8
- hydroqc/diagnostic.py +48 -5
- hydroqc/hydro_api/client.py +66 -10
- hydroqc/hydro_api/consts.py +6 -0
- hydroqc/peak/basepeak.py +67 -0
- hydroqc/peak/basepeakhandler.py +276 -0
- hydroqc/peak/consts.py +3 -0
- hydroqc/peak/cpc/consts.py +5 -3
- hydroqc/peak/cpc/handler.py +75 -178
- hydroqc/peak/cpc/peak.py +30 -84
- hydroqc/peak/dpc/consts.py +1 -4
- hydroqc/peak/dpc/handler.py +16 -176
- hydroqc/peak/dpc/peak.py +7 -21
- hydroqc/public_client.py +88 -0
- hydroqc/types/__init__.py +8 -1
- hydroqc/types/common.py +38 -7
- hydroqc/webuser.py +12 -8
- Hydro_Quebec_API_Wrapper-3.2.0.dist-info/RECORD +0 -49
- {Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info}/entry_points.txt +0 -0
- {Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info/licenses}/LICENSE +0 -0
- {Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info}/top_level.txt +0 -0
{Hydro_Quebec_API_Wrapper-3.2.0.dist-info → hydro_quebec_api_wrapper-4.1.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: Hydro-Quebec-API-Wrapper
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: A wrapper library to access hydro quebec API and more
|
|
5
5
|
Home-page: https://hydroqc.ca
|
|
6
6
|
Author-email: Hydroqc Team <info@hydroqc.ca>
|
|
@@ -12,14 +12,15 @@ Keywords: hydroquebec,lib
|
|
|
12
12
|
Platform: any
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
|
-
Requires-Python: >=3.
|
|
15
|
+
Requires-Python: >=3.13.0
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: aiohttp
|
|
19
|
-
Requires-Dist: python-dateutil
|
|
20
|
-
Requires-Dist: pytz
|
|
21
|
-
Requires-Dist: aiocache
|
|
22
|
-
Requires-Dist: pkce
|
|
18
|
+
Requires-Dist: aiohttp==3.13.2
|
|
19
|
+
Requires-Dist: python-dateutil==2.9.0.post0
|
|
20
|
+
Requires-Dist: pytz==2025.2
|
|
21
|
+
Requires-Dist: aiocache==0.12.3
|
|
22
|
+
Requires-Dist: pkce==1.0.3
|
|
23
|
+
Dynamic: license-file
|
|
23
24
|
|
|
24
25
|
# HydroQC - Hydro Quebec API wrapper
|
|
25
26
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
2
|
+
hydroqc/__init__.py,sha256=sFhCh7-LWoISCQuAtdrLQOmj2x5wjHBGbAAPg4SN6Pc,40
|
|
3
|
+
hydroqc/account.py,sha256=84PO2npB_VG8cEzGIbmXj9sD1whG8qynkiGd-yEYddM,3375
|
|
4
|
+
hydroqc/consts.py,sha256=a9dWq5i6t5VedYosUbP8zIuG2q5TPw4ruT0jOaC8Yo8,209
|
|
5
|
+
hydroqc/customer.py,sha256=Z3zq1p6ZwCXsxMnE8R6RmrGOCTxUFualMuu9MPRwQLI,6267
|
|
6
|
+
hydroqc/diagnostic.py,sha256=eVY3HfMcLCjTbKWo9xdaw14ygju4qUIKy9pxcQstoRc,17322
|
|
7
|
+
hydroqc/error.py,sha256=2HzWBak_RpuhfIrLhnfgNuY3FhUwwNyo1BLUDH6U0CI,598
|
|
8
|
+
hydroqc/logger.py,sha256=Fez6CqjBBxd841U3avtnrT3E43Vyy-v1e7hqwUmf9bg,1256
|
|
9
|
+
hydroqc/public_client.py,sha256=pUXA9rkgA8b4wIA3EMsd8FAC-swp-IRa4S-VK0v60SQ,3065
|
|
10
|
+
hydroqc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
hydroqc/timerange.py,sha256=MXR9yau72m4UZBSmN1qB0jMs0x4_jEZYnwtaUnGq-MQ,1137
|
|
12
|
+
hydroqc/utils.py,sha256=sxA5qkOA-Ui5jgEYItFQIeQdBsS_5z8J3xn8YxKZMow,232
|
|
13
|
+
hydroqc/webuser.py,sha256=MqlZNLLpuLGxHfRKyyVj-2SbDeWq7ERFZAnvvvzqVbo,4578
|
|
14
|
+
hydroqc/contract/__init__.py,sha256=uqxjOgyhpKFd-n_umxdaW5FB_DkJJaettWnEFC0nRYc,548
|
|
15
|
+
hydroqc/contract/common.py,sha256=xVw9z_Yjqp95SGCPNAfJVABvgp_C-KM51VTBEU9wjeM,15705
|
|
16
|
+
hydroqc/contract/contract_d.py,sha256=6jPYTCjFq8zonfbXPrEujDVz58n5RUEuq54VCGqph6o,856
|
|
17
|
+
hydroqc/contract/contract_d_cpc.py,sha256=-Y2S4MkzAfsbf_L2jCKfU7OD-nbzgoEpyT3SWh0U0tQ,1418
|
|
18
|
+
hydroqc/contract/contract_dpc.py,sha256=ITpSKBiB_QS7M894bZhKvuGpF4V1zLiPJCt1oHPMPzQ,5043
|
|
19
|
+
hydroqc/contract/contract_dt.py,sha256=TSKf2oh-MlG8A42xVUCCyf7oezlWTFoyATF9xlQn2JE,1687
|
|
20
|
+
hydroqc/contract/contract_m.py,sha256=2hSSb9Tw2eZu7PV1XicfTFKLCRiffq72NfOYiVz8QMk,2108
|
|
21
|
+
hydroqc/contract/contract_m_gdp.py,sha256=y8seZHmjkkul0TZ5Epxuxc4g0JVbs9o8KjL_y1gIldU,801
|
|
22
|
+
hydroqc/contract/contract_residential.py,sha256=v88mWvJsJP7FsY5cHmr0ZYYT_S-6xtSk1zvhTJ9UM4g,1456
|
|
23
|
+
hydroqc/contract/outage.py,sha256=K5XX0enSKMVpL-JCkWsykuKUw-5_GcSJLzcSR1SqQDk,3979
|
|
24
|
+
hydroqc/hydro_api/__init__.py,sha256=bIIjTkhQcXG7kn4cQr_Q6tFSKGjAx-AXLjMMlRCjclY,32
|
|
25
|
+
hydroqc/hydro_api/cache.py,sha256=mC3UO246V5zJ1p89nUb5EzQon_4tQGUgFMZKy4YY8I8,912
|
|
26
|
+
hydroqc/hydro_api/client.py,sha256=Sk0L_VpKaEiE6b_27Eq6nsaz10w7wMVh9wXeSE1x8jY,36537
|
|
27
|
+
hydroqc/hydro_api/consts.py,sha256=lLNlVgWZ21ExG6S_UZVeHcczFpm2YZMAOZRqzEy67c8,4632
|
|
28
|
+
hydroqc/peak/__init__.py,sha256=ye2KbWXhJEHZnBDaFylWioy3W-mzJw_lDplsJNAapNs,19
|
|
29
|
+
hydroqc/peak/basepeak.py,sha256=DMXjZXyNRHWnuhB0Vp3ZINGhNQngG7AU15cDLajmC7M,1954
|
|
30
|
+
hydroqc/peak/basepeakhandler.py,sha256=XVemlzDd2IeriDdvunvTxV7qwH1qEJcc0zm5-C716Ts,9184
|
|
31
|
+
hydroqc/peak/consts.py,sha256=2gUTZcDzu6Dia5g5w7-IG0JFt-9YdVopYcbHXjW3EK8,67
|
|
32
|
+
hydroqc/peak/cpc/__init__.py,sha256=sez6LQOUqDu6YVIpJexq9wYv3wef3I4TeCxwHhO9bBU,18
|
|
33
|
+
hydroqc/peak/cpc/consts.py,sha256=5PBf56YhsTMsZDkW0E_syN_byCVwLqS4ZFGG0_CWpsM,637
|
|
34
|
+
hydroqc/peak/cpc/handler.py,sha256=PEn4TTBu7-PTchNUmy3UxW7JVZ3QpFfKj06JHeJQn6M,12432
|
|
35
|
+
hydroqc/peak/cpc/peak.py,sha256=ptECO7_VSvT4fgOYSSqS_5kYPMHPHfgVjZr9M9MIKv4,4957
|
|
36
|
+
hydroqc/peak/dpc/__init__.py,sha256=H99D93OC4quEag-lQZ3BEF2mr5Qiu3DtvdKjBsiSRBg,18
|
|
37
|
+
hydroqc/peak/dpc/consts.py,sha256=FpnNUa29DgIzqqgtzues9TucEiMRwQq-HWeLzu3lUtY,464
|
|
38
|
+
hydroqc/peak/dpc/handler.py,sha256=fx0Rnum2Zz8vGsJENKsrWuFflzHp2NjH3dMPaHf-ulE,3408
|
|
39
|
+
hydroqc/peak/dpc/peak.py,sha256=clb1j6LaBndPo0qPlOxumGuUGYB4-_ob_s8UQa-m49o,1313
|
|
40
|
+
hydroqc/types/__init__.py,sha256=1dzth61xIsdteCEy2oVaavT78_djw-lUpzpXPRzQE40,1453
|
|
41
|
+
hydroqc/types/account.py,sha256=yXwqjU3lBG7cGt8RF0cyvNSxtBCaIoWgmtvsLisvQTY,3696
|
|
42
|
+
hydroqc/types/common.py,sha256=s1DA48svkJGsNaNUVcpEhoYLjiUOpfQI8WQ5xN6Yfco,1365
|
|
43
|
+
hydroqc/types/consump.py,sha256=-MIF6gZrOBI6ng6edBcI41sD5z6nDF3X3Kvoq-EjSoM,5929
|
|
44
|
+
hydroqc/types/contract.py,sha256=OTi8c5CEces3vwwQLbPzo1jB7sgwOweS1imFPnJMML0,1657
|
|
45
|
+
hydroqc/types/cpc.py,sha256=ghmtBTT1FKuqVodJJ0kCtUbYNTLCOrngxgcrzjJYvok,2116
|
|
46
|
+
hydroqc/types/dpc.py,sha256=5MGf3i74s6r4gJpFjNSgbN1v85VZO7dtu7pB5B4sgUQ,1328
|
|
47
|
+
hydroqc/types/dt.py,sha256=GzIY_5Bc-bVjYURN3O8Z3xVd9Y24mWYirSwBMhZjbPk,329
|
|
48
|
+
hydroqc/types/outage.py,sha256=XTsNyu8mmxUx44XWvOOUHKSoijp-lgbXwQroiqm9S0o,3932
|
|
49
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/METADATA,sha256=6J0KoXlxKr4-LWiEiRfTLZncGWtE9XCRPpaA7CMwbZg,7948
|
|
50
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
51
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/entry_points.txt,sha256=G2YKkCH9rFt2dXbFyHINBp4bmqY2HTEIaf7F1CwbC_k,57
|
|
52
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/top_level.txt,sha256=YAcYLnu5YYkbxt1psUoBfo_opl-lAZKq0A7B3IN_P6M,8
|
|
53
|
+
hydro_quebec_api_wrapper-4.1.0.dist-info/RECORD,,
|
hydroqc/account.py
CHANGED
hydroqc/contract/common.py
CHANGED
|
@@ -27,7 +27,7 @@ P = ParamSpec("P")
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def check_period_data_present(
|
|
30
|
-
method: Callable[..., None | str | bool | float | PeriodDataTyping]
|
|
30
|
+
method: Callable[..., None | str | bool | float | PeriodDataTyping],
|
|
31
31
|
) -> Callable[..., None | str | bool | float | PeriodDataTyping]:
|
|
32
32
|
"""Check if contract's data are present."""
|
|
33
33
|
|
|
@@ -47,7 +47,7 @@ def check_period_data_present(
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
def check_info_data_present(
|
|
50
|
-
method: Callable[..., None | str | bool | float | date]
|
|
50
|
+
method: Callable[..., None | str | bool | float | date],
|
|
51
51
|
) -> Callable[..., None | str | bool | float | date]:
|
|
52
52
|
"""Check if contract's data are present."""
|
|
53
53
|
|
|
@@ -67,7 +67,7 @@ def check_info_data_present(
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def check_annual_data_present(
|
|
70
|
-
method: Callable[..., None | str | bool | float | date]
|
|
70
|
+
method: Callable[..., None | str | bool | float | date],
|
|
71
71
|
) -> Callable[..., None | str | bool | float | date]:
|
|
72
72
|
"""Check if contract's data are present."""
|
|
73
73
|
|
|
@@ -124,6 +124,7 @@ class Contract(ABC):
|
|
|
124
124
|
self,
|
|
125
125
|
applicant_id: str,
|
|
126
126
|
customer_id: str,
|
|
127
|
+
*,
|
|
127
128
|
account_id: str,
|
|
128
129
|
contract_id: str,
|
|
129
130
|
hydro_client: HydroClient,
|
|
@@ -273,7 +274,11 @@ class Contract(ABC):
|
|
|
273
274
|
) -> ConsumpDailyTyping:
|
|
274
275
|
"""Fetch daily consumption."""
|
|
275
276
|
return await self._hydro_client.get_daily_consumption(
|
|
276
|
-
self.applicant_id,
|
|
277
|
+
self.applicant_id,
|
|
278
|
+
self.customer_id,
|
|
279
|
+
contract_id=self.contract_id,
|
|
280
|
+
start_date=start_date,
|
|
281
|
+
end_date=end_date,
|
|
277
282
|
)
|
|
278
283
|
|
|
279
284
|
async def get_today_daily_consumption(self) -> ConsumpDailyTyping:
|
|
@@ -313,11 +318,11 @@ class Contract(ABC):
|
|
|
313
318
|
data_csv = await self._hydro_client.get_consumption_csv(
|
|
314
319
|
self.applicant_id,
|
|
315
320
|
self.customer_id,
|
|
316
|
-
self.contract_id,
|
|
317
|
-
start_date,
|
|
318
|
-
end_date,
|
|
319
|
-
"energie-jour",
|
|
320
|
-
raw_output,
|
|
321
|
+
contract_id=self.contract_id,
|
|
322
|
+
start_date=start_date,
|
|
323
|
+
end_date=end_date,
|
|
324
|
+
option="energie-jour",
|
|
325
|
+
raw_output=raw_output,
|
|
321
326
|
)
|
|
322
327
|
return data_csv
|
|
323
328
|
|
|
@@ -334,11 +339,11 @@ class Contract(ABC):
|
|
|
334
339
|
data_csv = await self._hydro_client.get_consumption_csv(
|
|
335
340
|
self.applicant_id,
|
|
336
341
|
self.customer_id,
|
|
337
|
-
self.contract_id,
|
|
338
|
-
start_date,
|
|
339
|
-
end_date,
|
|
340
|
-
"energie-heure",
|
|
341
|
-
raw_output,
|
|
342
|
+
contract_id=self.contract_id,
|
|
343
|
+
start_date=start_date,
|
|
344
|
+
end_date=end_date,
|
|
345
|
+
option="energie-heure",
|
|
346
|
+
raw_output=raw_output,
|
|
342
347
|
)
|
|
343
348
|
return data_csv
|
|
344
349
|
|
|
@@ -379,7 +384,7 @@ class Contract(ABC):
|
|
|
379
384
|
@check_period_data_present
|
|
380
385
|
def cp_projected_bill(self) -> float:
|
|
381
386
|
"""Projected bill of the current period."""
|
|
382
|
-
return self._all_period_data[0]["montantProjetePeriode"]
|
|
387
|
+
return float(self._all_period_data[0]["montantProjetePeriode"])
|
|
383
388
|
|
|
384
389
|
@property
|
|
385
390
|
@check_period_data_present
|
|
@@ -453,6 +458,7 @@ class ContractFallBack(Contract):
|
|
|
453
458
|
self,
|
|
454
459
|
applicant_id: str,
|
|
455
460
|
customer_id: str,
|
|
461
|
+
*,
|
|
456
462
|
account_id: str,
|
|
457
463
|
contract_id: str,
|
|
458
464
|
hydro_client: HydroClient,
|
|
@@ -463,8 +469,8 @@ class ContractFallBack(Contract):
|
|
|
463
469
|
self,
|
|
464
470
|
applicant_id,
|
|
465
471
|
customer_id,
|
|
466
|
-
account_id,
|
|
467
|
-
contract_id,
|
|
468
|
-
hydro_client,
|
|
469
|
-
log_level,
|
|
472
|
+
account_id=account_id,
|
|
473
|
+
contract_id=contract_id,
|
|
474
|
+
hydro_client=hydro_client,
|
|
475
|
+
log_level=log_level,
|
|
470
476
|
)
|
hydroqc/contract/contract_d.py
CHANGED
|
@@ -17,6 +17,7 @@ class ContractD(ContractResidential):
|
|
|
17
17
|
self,
|
|
18
18
|
applicant_id: str,
|
|
19
19
|
customer_id: str,
|
|
20
|
+
*,
|
|
20
21
|
account_id: str,
|
|
21
22
|
contract_id: str,
|
|
22
23
|
hydro_client: HydroClient,
|
|
@@ -27,8 +28,8 @@ class ContractD(ContractResidential):
|
|
|
27
28
|
self,
|
|
28
29
|
applicant_id,
|
|
29
30
|
customer_id,
|
|
30
|
-
account_id,
|
|
31
|
-
contract_id,
|
|
32
|
-
hydro_client,
|
|
33
|
-
log_level,
|
|
31
|
+
account_id=account_id,
|
|
32
|
+
contract_id=contract_id,
|
|
33
|
+
hydro_client=hydro_client,
|
|
34
|
+
log_level=log_level,
|
|
34
35
|
)
|
|
@@ -17,6 +17,7 @@ class ContractDCPC(ContractD):
|
|
|
17
17
|
self,
|
|
18
18
|
applicant_id: str,
|
|
19
19
|
customer_id: str,
|
|
20
|
+
*,
|
|
20
21
|
account_id: str,
|
|
21
22
|
contract_id: str,
|
|
22
23
|
hydro_client: HydroClient,
|
|
@@ -27,18 +28,18 @@ class ContractDCPC(ContractD):
|
|
|
27
28
|
self,
|
|
28
29
|
applicant_id,
|
|
29
30
|
customer_id,
|
|
30
|
-
account_id,
|
|
31
|
-
contract_id,
|
|
32
|
-
hydro_client,
|
|
33
|
-
log_level,
|
|
31
|
+
account_id=account_id,
|
|
32
|
+
contract_id=contract_id,
|
|
33
|
+
hydro_client=hydro_client,
|
|
34
|
+
log_level=log_level,
|
|
34
35
|
)
|
|
35
36
|
wch_logger = self._logger.getChild("wch")
|
|
36
37
|
self._wch: CPCPeakHandler = CPCPeakHandler(
|
|
37
38
|
self.applicant_id,
|
|
38
39
|
self.customer_id,
|
|
39
|
-
self.contract_id,
|
|
40
|
-
hydro_client,
|
|
41
|
-
wch_logger,
|
|
40
|
+
contract_id=self.contract_id,
|
|
41
|
+
hydro_client=hydro_client,
|
|
42
|
+
logger=wch_logger,
|
|
42
43
|
)
|
|
43
44
|
|
|
44
45
|
@property
|
hydroqc/contract/contract_dpc.py
CHANGED
|
@@ -11,7 +11,7 @@ from hydroqc.types import DPCDataTyping
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def check_dpc_data_present(
|
|
14
|
-
method: Callable[..., None | str | bool | float | date]
|
|
14
|
+
method: Callable[..., None | str | bool | float | date],
|
|
15
15
|
) -> Callable[..., None | str | bool | float | date]:
|
|
16
16
|
"""Check if contractDPC's data are present."""
|
|
17
17
|
|
|
@@ -45,6 +45,7 @@ class ContractDPC(ContractResidential):
|
|
|
45
45
|
self,
|
|
46
46
|
applicant_id: str,
|
|
47
47
|
customer_id: str,
|
|
48
|
+
*,
|
|
48
49
|
account_id: str,
|
|
49
50
|
contract_id: str,
|
|
50
51
|
hydro_client: HydroClient,
|
|
@@ -55,18 +56,18 @@ class ContractDPC(ContractResidential):
|
|
|
55
56
|
self,
|
|
56
57
|
applicant_id,
|
|
57
58
|
customer_id,
|
|
58
|
-
account_id,
|
|
59
|
-
contract_id,
|
|
60
|
-
hydro_client,
|
|
61
|
-
log_level,
|
|
59
|
+
account_id=account_id,
|
|
60
|
+
contract_id=contract_id,
|
|
61
|
+
hydro_client=hydro_client,
|
|
62
|
+
log_level=log_level,
|
|
62
63
|
)
|
|
63
64
|
peaks_logger = self._logger.getChild("peaks")
|
|
64
65
|
self._peakh: DPCPeakHandler = DPCPeakHandler(
|
|
65
66
|
self.applicant_id,
|
|
66
67
|
self.customer_id,
|
|
67
|
-
self.contract_id,
|
|
68
|
-
hydro_client,
|
|
69
|
-
peaks_logger,
|
|
68
|
+
contract_id=self.contract_id,
|
|
69
|
+
hydro_client=hydro_client,
|
|
70
|
+
logger=peaks_logger,
|
|
70
71
|
)
|
|
71
72
|
|
|
72
73
|
@property
|
hydroqc/contract/contract_dt.py
CHANGED
|
@@ -18,6 +18,7 @@ class ContractDT(ContractResidential):
|
|
|
18
18
|
self,
|
|
19
19
|
applicant_id: str,
|
|
20
20
|
customer_id: str,
|
|
21
|
+
*,
|
|
21
22
|
account_id: str,
|
|
22
23
|
contract_id: str,
|
|
23
24
|
hydro_client: HydroClient,
|
|
@@ -28,10 +29,10 @@ class ContractDT(ContractResidential):
|
|
|
28
29
|
self,
|
|
29
30
|
applicant_id,
|
|
30
31
|
customer_id,
|
|
31
|
-
account_id,
|
|
32
|
-
contract_id,
|
|
33
|
-
hydro_client,
|
|
34
|
-
log_level,
|
|
32
|
+
account_id=account_id,
|
|
33
|
+
contract_id=contract_id,
|
|
34
|
+
hydro_client=hydro_client,
|
|
35
|
+
log_level=log_level,
|
|
35
36
|
)
|
|
36
37
|
|
|
37
38
|
@property
|
hydroqc/contract/contract_m.py
CHANGED
|
@@ -21,6 +21,7 @@ class ContractM(Contract):
|
|
|
21
21
|
self,
|
|
22
22
|
applicant_id: str,
|
|
23
23
|
customer_id: str,
|
|
24
|
+
*,
|
|
24
25
|
account_id: str,
|
|
25
26
|
contract_id: str,
|
|
26
27
|
hydro_client: HydroClient,
|
|
@@ -31,10 +32,10 @@ class ContractM(Contract):
|
|
|
31
32
|
self,
|
|
32
33
|
applicant_id,
|
|
33
34
|
customer_id,
|
|
34
|
-
account_id,
|
|
35
|
-
contract_id,
|
|
36
|
-
hydro_client,
|
|
37
|
-
log_level,
|
|
35
|
+
account_id=account_id,
|
|
36
|
+
contract_id=contract_id,
|
|
37
|
+
hydro_client=hydro_client,
|
|
38
|
+
log_level=log_level,
|
|
38
39
|
)
|
|
39
40
|
|
|
40
41
|
async def get_power_demand_per_15min(
|
|
@@ -47,11 +48,11 @@ class ContractM(Contract):
|
|
|
47
48
|
data_csv = await self._hydro_client.get_consumption_csv(
|
|
48
49
|
self.applicant_id,
|
|
49
50
|
self.customer_id,
|
|
50
|
-
self.contract_id,
|
|
51
|
-
start_date,
|
|
52
|
-
end_date,
|
|
53
|
-
"puissance-min",
|
|
54
|
-
raw_output,
|
|
51
|
+
contract_id=self.contract_id,
|
|
52
|
+
start_date=start_date,
|
|
53
|
+
end_date=end_date,
|
|
54
|
+
option="puissance-min",
|
|
55
|
+
raw_output=raw_output,
|
|
55
56
|
)
|
|
56
57
|
return data_csv
|
|
57
58
|
|
|
@@ -65,10 +66,10 @@ class ContractM(Contract):
|
|
|
65
66
|
data_csv = await self._hydro_client.get_consumption_csv(
|
|
66
67
|
self.applicant_id,
|
|
67
68
|
self.customer_id,
|
|
68
|
-
self.contract_id,
|
|
69
|
-
start_date,
|
|
70
|
-
end_date,
|
|
71
|
-
"puissance-jour",
|
|
72
|
-
raw_output,
|
|
69
|
+
contract_id=self.contract_id,
|
|
70
|
+
start_date=start_date,
|
|
71
|
+
end_date=end_date,
|
|
72
|
+
option="puissance-jour",
|
|
73
|
+
raw_output=raw_output,
|
|
73
74
|
)
|
|
74
75
|
return data_csv
|
|
@@ -16,6 +16,7 @@ class ContractMGDP(ContractM):
|
|
|
16
16
|
self,
|
|
17
17
|
applicant_id: str,
|
|
18
18
|
customer_id: str,
|
|
19
|
+
*,
|
|
19
20
|
account_id: str,
|
|
20
21
|
contract_id: str,
|
|
21
22
|
hydro_client: HydroClient,
|
|
@@ -26,8 +27,8 @@ class ContractMGDP(ContractM):
|
|
|
26
27
|
self,
|
|
27
28
|
applicant_id,
|
|
28
29
|
customer_id,
|
|
29
|
-
account_id,
|
|
30
|
-
contract_id,
|
|
31
|
-
hydro_client,
|
|
32
|
-
log_level,
|
|
30
|
+
account_id=account_id,
|
|
31
|
+
contract_id=contract_id,
|
|
32
|
+
hydro_client=hydro_client,
|
|
33
|
+
log_level=log_level,
|
|
33
34
|
)
|
|
@@ -18,6 +18,7 @@ class ContractResidential(Contract):
|
|
|
18
18
|
self,
|
|
19
19
|
applicant_id: str,
|
|
20
20
|
customer_id: str,
|
|
21
|
+
*,
|
|
21
22
|
account_id: str,
|
|
22
23
|
contract_id: str,
|
|
23
24
|
hydro_client: HydroClient,
|
|
@@ -28,10 +29,10 @@ class ContractResidential(Contract):
|
|
|
28
29
|
self,
|
|
29
30
|
applicant_id,
|
|
30
31
|
customer_id,
|
|
31
|
-
account_id,
|
|
32
|
-
contract_id,
|
|
33
|
-
hydro_client,
|
|
34
|
-
log_level,
|
|
32
|
+
account_id=account_id,
|
|
33
|
+
contract_id=contract_id,
|
|
34
|
+
hydro_client=hydro_client,
|
|
35
|
+
log_level=log_level,
|
|
35
36
|
)
|
|
36
37
|
|
|
37
38
|
async def get_daily_energy(
|
|
@@ -44,10 +45,10 @@ class ContractResidential(Contract):
|
|
|
44
45
|
data_csv = await self._hydro_client.get_consumption_csv(
|
|
45
46
|
self.applicant_id,
|
|
46
47
|
self.customer_id,
|
|
47
|
-
self.contract_id,
|
|
48
|
-
start_date,
|
|
49
|
-
end_date,
|
|
50
|
-
"energie-jour",
|
|
51
|
-
raw_output,
|
|
48
|
+
contract_id=self.contract_id,
|
|
49
|
+
start_date=start_date,
|
|
50
|
+
end_date=end_date,
|
|
51
|
+
option="energie-jour",
|
|
52
|
+
raw_output=raw_output,
|
|
52
53
|
)
|
|
53
54
|
return data_csv
|
hydroqc/customer.py
CHANGED
|
@@ -19,6 +19,7 @@ class Customer:
|
|
|
19
19
|
self,
|
|
20
20
|
applicant_id: str,
|
|
21
21
|
customer_id: str,
|
|
22
|
+
*,
|
|
22
23
|
customer_names: list[str],
|
|
23
24
|
hydro_client: HydroClient,
|
|
24
25
|
log_level: str | None = None,
|
|
@@ -71,10 +72,10 @@ class Customer:
|
|
|
71
72
|
account = Account(
|
|
72
73
|
self.applicant_id,
|
|
73
74
|
self.customer_id,
|
|
74
|
-
account_id,
|
|
75
|
-
[],
|
|
76
|
-
self._hydro_client,
|
|
77
|
-
self._log_level,
|
|
75
|
+
account_id=account_id,
|
|
76
|
+
contracts=[],
|
|
77
|
+
hydro_client=self._hydro_client,
|
|
78
|
+
log_level=self._log_level,
|
|
78
79
|
)
|
|
79
80
|
self.accounts.append(account)
|
|
80
81
|
else:
|
|
@@ -103,10 +104,10 @@ class Customer:
|
|
|
103
104
|
contract = getattr(contractModule, contract_class_name)(
|
|
104
105
|
self.applicant_id,
|
|
105
106
|
self.customer_id,
|
|
106
|
-
account_id,
|
|
107
|
-
contract_id,
|
|
108
|
-
self._hydro_client,
|
|
109
|
-
self._log_level,
|
|
107
|
+
account_id=account_id,
|
|
108
|
+
contract_id=contract_id,
|
|
109
|
+
hydro_client=self._hydro_client,
|
|
110
|
+
log_level=self._log_level,
|
|
110
111
|
)
|
|
111
112
|
account.contracts.append(contract)
|
|
112
113
|
else:
|
hydroqc/diagnostic.py
CHANGED
|
@@ -20,6 +20,7 @@ from dateutil.relativedelta import relativedelta
|
|
|
20
20
|
from hydroqc.contract import ContractDCPC, ContractDPC, ContractM
|
|
21
21
|
from hydroqc.error import HydroQcError
|
|
22
22
|
from hydroqc.logger import get_logger
|
|
23
|
+
from hydroqc.public_client import PublicClient
|
|
23
24
|
from hydroqc.webuser import WebUser
|
|
24
25
|
|
|
25
26
|
LOG_LEVEL = (
|
|
@@ -39,10 +40,12 @@ class Diagnostic:
|
|
|
39
40
|
"""Contructor."""
|
|
40
41
|
# Get base settings
|
|
41
42
|
self.diagnostic_folder = cli_settings.output_folder
|
|
43
|
+
self.diagnostic_folder_public = os.path.join(self.diagnostic_folder, "public")
|
|
42
44
|
# Prepare output folder
|
|
43
45
|
if os.path.exists(self.diagnostic_folder):
|
|
44
46
|
shutil.rmtree(self.diagnostic_folder)
|
|
45
47
|
os.makedirs(self.diagnostic_folder)
|
|
48
|
+
os.makedirs(self.diagnostic_folder_public)
|
|
46
49
|
# Prepare logger
|
|
47
50
|
self._log_file = os.path.join(self.diagnostic_folder, "diagnostic.log")
|
|
48
51
|
log_level = cli_settings.log_level
|
|
@@ -51,6 +54,7 @@ class Diagnostic:
|
|
|
51
54
|
file_handler.setFormatter(self.logger.handlers[0].formatter)
|
|
52
55
|
file_handler.setLevel(self.logger.level)
|
|
53
56
|
self.logger.addHandler(file_handler)
|
|
57
|
+
self.logger_public = self.logger.getChild("public")
|
|
54
58
|
http_log_level = cli_settings.http_log_level
|
|
55
59
|
|
|
56
60
|
# Get settings
|
|
@@ -69,6 +73,15 @@ class Diagnostic:
|
|
|
69
73
|
log_file=self._log_file,
|
|
70
74
|
diag_folder=self.diagnostic_folder,
|
|
71
75
|
)
|
|
76
|
+
self.public_client = PublicClient(
|
|
77
|
+
rate_code="DPC",
|
|
78
|
+
# rate_option_code="CPC",
|
|
79
|
+
verify_ssl=True,
|
|
80
|
+
log_level=log_level,
|
|
81
|
+
http_log_level=http_log_level,
|
|
82
|
+
log_file=self._log_file,
|
|
83
|
+
diag_folder=self.diagnostic_folder_public,
|
|
84
|
+
)
|
|
72
85
|
|
|
73
86
|
def zip(self) -> None:
|
|
74
87
|
"""Archive all generated files."""
|
|
@@ -87,6 +100,11 @@ class Diagnostic:
|
|
|
87
100
|
"""Get diagnostic http ID."""
|
|
88
101
|
return self.webuser._hydro_client._diag_id
|
|
89
102
|
|
|
103
|
+
@property
|
|
104
|
+
def public_diag_id(self) -> int:
|
|
105
|
+
"""Get diagnostic http ID."""
|
|
106
|
+
return self.public_client._hydro_client._diag_id
|
|
107
|
+
|
|
90
108
|
async def run(self) -> None: # pylint: disable=too-many-statements
|
|
91
109
|
"""Run diagnostic."""
|
|
92
110
|
today = datetime.date.today()
|
|
@@ -94,6 +112,24 @@ class Diagnostic:
|
|
|
94
112
|
day_2 = today - datetime.timedelta(days=2)
|
|
95
113
|
|
|
96
114
|
try:
|
|
115
|
+
self.logger_public.info(
|
|
116
|
+
"%02d - Checking HQ portal status", self.public_diag_id
|
|
117
|
+
)
|
|
118
|
+
hq_status = await self.public_client.check_hq_portal_status()
|
|
119
|
+
self.logger_public.info(
|
|
120
|
+
"%02d - HQ portal available: %s", self.public_diag_id - 1, hq_status
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
self.logger_public.info(
|
|
124
|
+
"%02d - Fetch peak using open data", self.public_diag_id
|
|
125
|
+
)
|
|
126
|
+
await self.public_client.fetch_peak_data()
|
|
127
|
+
self.logger_public.info(
|
|
128
|
+
"%02d - Peak found: %s",
|
|
129
|
+
self.public_diag_id - 1,
|
|
130
|
+
len(self.public_client.peaks),
|
|
131
|
+
)
|
|
132
|
+
|
|
97
133
|
self.logger.info("%02d - Checking HQ portal status", self.diag_id)
|
|
98
134
|
hq_status = await self.webuser.check_hq_portal_status()
|
|
99
135
|
self.logger.info(
|
|
@@ -267,6 +303,10 @@ class Diagnostic:
|
|
|
267
303
|
await contract_dcpc.peak_handler.refresh_data()
|
|
268
304
|
self.logger.info("%02d - Got cpc data", self.diag_id - 1)
|
|
269
305
|
|
|
306
|
+
self.logger.info("%02d - Trying to get opn data", self.diag_id)
|
|
307
|
+
await contract_dcpc.peak_handler.refresh_open_data()
|
|
308
|
+
self.logger.info("%02d - Got open data", self.diag_id - 1)
|
|
309
|
+
|
|
270
310
|
# DCP/FlexD
|
|
271
311
|
elif self.contract.rate == "DPC":
|
|
272
312
|
self.logger.info("%02d - Trying to get flexD data", self.diag_id)
|
|
@@ -289,6 +329,10 @@ class Diagnostic:
|
|
|
289
329
|
await contract_dpc.peak_handler.refresh_data()
|
|
290
330
|
self.logger.info("%02d - Got flexD data", self.diag_id - 1)
|
|
291
331
|
|
|
332
|
+
self.logger.info("%02d - Trying to get opn data", self.diag_id)
|
|
333
|
+
await contract_dcpc.peak_handler.refresh_open_data()
|
|
334
|
+
self.logger.info("%02d - Got open data", self.diag_id - 1)
|
|
335
|
+
|
|
292
336
|
# DT
|
|
293
337
|
if self.contract.rate == "DT":
|
|
294
338
|
low_price = contract_dpc.cp_lower_price_consumption
|
|
@@ -330,6 +374,9 @@ class Diagnostic:
|
|
|
330
374
|
traceback.print_exception(exp, file=fhtb)
|
|
331
375
|
fhtb.seek(0)
|
|
332
376
|
self.logger.error(fhtb.read())
|
|
377
|
+
finally:
|
|
378
|
+
await self.webuser.close_session()
|
|
379
|
+
await self.public_client.close_session()
|
|
333
380
|
|
|
334
381
|
|
|
335
382
|
def parse_args() -> argparse.Namespace:
|
|
@@ -380,14 +427,10 @@ def main() -> None:
|
|
|
380
427
|
"""Run diagnostic."""
|
|
381
428
|
cli_settings = parse_args()
|
|
382
429
|
|
|
383
|
-
loop = asyncio.get_event_loop()
|
|
384
430
|
diag = Diagnostic(cli_settings)
|
|
385
431
|
|
|
386
432
|
# Fetch data
|
|
387
|
-
|
|
388
|
-
close_fut = asyncio.gather(diag.webuser.close_session())
|
|
389
|
-
loop.run_until_complete(close_fut)
|
|
390
|
-
loop.close()
|
|
433
|
+
asyncio.run(diag.run())
|
|
391
434
|
# zip
|
|
392
435
|
diag.zip()
|
|
393
436
|
|