gazpar2haws 0.1.11__py3-none-any.whl → 0.1.13__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.
- gazpar2haws/bridge.py +23 -2
- gazpar2haws/gazpar.py +54 -4
- {gazpar2haws-0.1.11.dist-info → gazpar2haws-0.1.13.dist-info}/METADATA +1 -1
- {gazpar2haws-0.1.11.dist-info → gazpar2haws-0.1.13.dist-info}/RECORD +6 -6
- {gazpar2haws-0.1.11.dist-info → gazpar2haws-0.1.13.dist-info}/LICENSE +0 -0
- {gazpar2haws-0.1.11.dist-info → gazpar2haws-0.1.13.dist-info}/WHEEL +0 -0
gazpar2haws/bridge.py
CHANGED
@@ -16,12 +16,30 @@ class Bridge:
|
|
16
16
|
def __init__(self, config: config_utils.ConfigLoader):
|
17
17
|
|
18
18
|
# GrDF scan interval (in seconds)
|
19
|
+
if config.get("grdf.scan_interval") is None:
|
20
|
+
raise ValueError("Configuration parameter 'grdf.scan_interval' is missing")
|
19
21
|
self._grdf_scan_interval = int(config.get("grdf.scan_interval"))
|
20
22
|
|
21
|
-
# Home Assistant configuration
|
23
|
+
# Home Assistant configuration: host
|
24
|
+
if config.get("homeassistant.host") is None:
|
25
|
+
raise ValueError("Configuration parameter 'homeassistant.host' is missing")
|
22
26
|
ha_host = config.get("homeassistant.host")
|
27
|
+
|
28
|
+
# Home Assistant configuration: port
|
29
|
+
if config.get("homeassistant.port") is None:
|
30
|
+
raise ValueError("Configuration parameter 'homeassistant.port' is missing")
|
23
31
|
ha_port = config.get("homeassistant.port")
|
24
|
-
|
32
|
+
|
33
|
+
# Home Assistant configuration: endpoint
|
34
|
+
ha_endpoint = (
|
35
|
+
config.get("homeassistant.endpoint")
|
36
|
+
if config.get("homeassistant.endpoint")
|
37
|
+
else "/api/websocket"
|
38
|
+
)
|
39
|
+
|
40
|
+
# Home Assistant configuration: token
|
41
|
+
if config.get("homeassistant.token") is None:
|
42
|
+
raise ValueError("Configuration parameter 'homeassistant.token' is missing")
|
25
43
|
ha_token = config.get("homeassistant.token")
|
26
44
|
|
27
45
|
# Initialize Home Assistant
|
@@ -29,6 +47,9 @@ class Bridge:
|
|
29
47
|
|
30
48
|
# Initialize Gazpar
|
31
49
|
self._gazpar = []
|
50
|
+
|
51
|
+
if config.get("grdf.devices") is None:
|
52
|
+
raise ValueError("Configuration parameter 'grdf.devices' is missing")
|
32
53
|
for grdf_device_config in config.get("grdf.devices"):
|
33
54
|
self._gazpar.append(Gazpar(grdf_device_config, self._homeassistant))
|
34
55
|
|
gazpar2haws/gazpar.py
CHANGED
@@ -19,15 +19,59 @@ class Gazpar:
|
|
19
19
|
|
20
20
|
self._homeassistant = homeassistant
|
21
21
|
|
22
|
-
# GrDF configuration
|
22
|
+
# GrDF configuration: name
|
23
|
+
if config.get("name") is None:
|
24
|
+
raise ValueError("Configuration parameter 'grdf.devices[].name' is missing")
|
23
25
|
self._name = config.get("name")
|
24
|
-
|
26
|
+
|
27
|
+
# GrDF configuration: data source
|
28
|
+
self._data_source = (
|
29
|
+
config.get("data_source") if config.get("data_source") else "json"
|
30
|
+
)
|
31
|
+
|
32
|
+
# GrDF configuration: username
|
33
|
+
if self._data_source != "test" and config.get("username") is None:
|
34
|
+
raise ValueError(
|
35
|
+
"Configuration parameter 'grdf.devices[].username' is missing"
|
36
|
+
)
|
25
37
|
self._username = config.get("username")
|
38
|
+
|
39
|
+
# GrDF configuration: password
|
40
|
+
if self._data_source != "test" and config.get("password") is None:
|
41
|
+
raise ValueError(
|
42
|
+
"Configuration parameter 'grdf.devices[].password' is missing"
|
43
|
+
)
|
26
44
|
self._password = config.get("password")
|
45
|
+
|
46
|
+
# GrDF configuration: pce_identifier
|
47
|
+
if self._data_source != "test" and config.get("pce_identifier") is None:
|
48
|
+
raise ValueError(
|
49
|
+
"Configuration parameter 'grdf.devices[].pce_identifier' is missing"
|
50
|
+
)
|
27
51
|
self._pce_identifier = str(config.get("pce_identifier"))
|
28
|
-
|
52
|
+
|
53
|
+
# GrDF configuration: tmp_dir
|
54
|
+
self._tmp_dir = config.get("tmp_dir") if config.get("tmp_dir") else "/tmp"
|
55
|
+
|
56
|
+
# GrDF configuration: last_days
|
57
|
+
if config.get("last_days") is None:
|
58
|
+
raise ValueError(
|
59
|
+
"Configuration parameter 'grdf.devices[].last_days' is missing"
|
60
|
+
)
|
29
61
|
self._last_days = int(str(config.get("last_days")))
|
62
|
+
|
63
|
+
# GrDF configuration: timezone
|
64
|
+
if config.get("timezone") is None:
|
65
|
+
raise ValueError(
|
66
|
+
"Configuration parameter 'grdf.devices[].timezone' is missing"
|
67
|
+
)
|
30
68
|
self._timezone = str(config.get("timezone"))
|
69
|
+
|
70
|
+
# GrDF configuration: reset
|
71
|
+
if config.get("reset") is None:
|
72
|
+
raise ValueError(
|
73
|
+
"Configuration parameter 'grdf.devices[].reset' is missing"
|
74
|
+
)
|
31
75
|
self._reset = bool(config.get("reset"))
|
32
76
|
|
33
77
|
# As of date: YYYY-MM-DD
|
@@ -129,7 +173,13 @@ class Gazpar:
|
|
129
173
|
continue
|
130
174
|
|
131
175
|
# Compute the total volume and energy
|
132
|
-
|
176
|
+
if reading[property_name] is not None:
|
177
|
+
total += reading[property_name]
|
178
|
+
else:
|
179
|
+
Logger.warning(
|
180
|
+
f"Missing property {property_name} for date {date}. Skipping..."
|
181
|
+
)
|
182
|
+
continue
|
133
183
|
|
134
184
|
statistics.append({"start": date.isoformat(), "state": total, "sum": total})
|
135
185
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
gazpar2haws/__init__.py,sha256=3MCDQdGGmT3FQMKaAB3mBJq7L75T_bJSdpDRjE-pado,58
|
2
2
|
gazpar2haws/__main__.py,sha256=KdhkowqJP6L8WTF9FNpTy4ZzDf1OPARm6mVtMclxGFk,3265
|
3
|
-
gazpar2haws/bridge.py,sha256=
|
3
|
+
gazpar2haws/bridge.py,sha256=IDunENo7bQ9NDov76IEefAkMOen-6Wc_2NZcHGyk_XI,4601
|
4
4
|
gazpar2haws/config_utils.py,sha256=89ClKudFGxiT_EnzqRhfEvYVm9SeWq6U2xhNjvm3hhs,2161
|
5
|
-
gazpar2haws/gazpar.py,sha256=
|
5
|
+
gazpar2haws/gazpar.py,sha256=29RfLxBaBCpoopOBpCX3xh681Ksm5pjZlLu9l3PqTAI,10321
|
6
6
|
gazpar2haws/haws.py,sha256=H--UWGECYq9JYlbU6IHLO2btaRXInwoVRZnHIXSA1ts,8169
|
7
7
|
gazpar2haws/version.py,sha256=9Iq5Jm63Ev7QquCjhDqa9_KAgHdKl9FJHynq8M6JNrY,83
|
8
|
-
gazpar2haws-0.1.
|
9
|
-
gazpar2haws-0.1.
|
10
|
-
gazpar2haws-0.1.
|
11
|
-
gazpar2haws-0.1.
|
8
|
+
gazpar2haws-0.1.13.dist-info/LICENSE,sha256=ajApZPyhVx8AU9wN7DXeRGhoWFqY2ylBZUa5GRhTmok,1073
|
9
|
+
gazpar2haws-0.1.13.dist-info/METADATA,sha256=Ec0DozzMhiKWUjHD2IaD0P0LYeRKe94dqwgJ5XkVDFE,9451
|
10
|
+
gazpar2haws-0.1.13.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
11
|
+
gazpar2haws-0.1.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|