ekzexport 0.1.0__tar.gz
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.
- ekzexport-0.1.0/LICENSE +174 -0
- ekzexport-0.1.0/PKG-INFO +153 -0
- ekzexport-0.1.0/README.md +126 -0
- ekzexport-0.1.0/setup.cfg +4 -0
- ekzexport-0.1.0/setup.py +48 -0
- ekzexport-0.1.0/src/ekzexport/__init__.py +0 -0
- ekzexport-0.1.0/src/ekzexport/apitypes.py +120 -0
- ekzexport-0.1.0/src/ekzexport/cli.py +167 -0
- ekzexport-0.1.0/src/ekzexport/session.py +80 -0
- ekzexport-0.1.0/src/ekzexport/timeutil.py +68 -0
- ekzexport-0.1.0/src/ekzexport/util.py +275 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/PKG-INFO +153 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/SOURCES.txt +17 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/dependency_links.txt +1 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/entry_points.txt +2 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/requires.txt +9 -0
- ekzexport-0.1.0/src/ekzexport.egg-info/top_level.txt +1 -0
- ekzexport-0.1.0/tests/test_timeutil.py +24 -0
- ekzexport-0.1.0/tests/test_util.py +181 -0
ekzexport-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
ekzexport-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ekzexport
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI and data exporter for the myEKZ customer portal.
|
|
5
|
+
Home-page: https://github.com/mensi/ekzexport
|
|
6
|
+
Author: Manuel Stocker
|
|
7
|
+
Author-email: mensi@mensi.ch
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests
|
|
20
|
+
Requires-Dist: click
|
|
21
|
+
Requires-Dist: beautifulsoup4
|
|
22
|
+
Requires-Dist: rich
|
|
23
|
+
Requires-Dist: platformdirs
|
|
24
|
+
Requires-Dist: tzdata
|
|
25
|
+
Provides-Extra: influx
|
|
26
|
+
Requires-Dist: influxdb-client; extra == "influx"
|
|
27
|
+
|
|
28
|
+
# ekzexport
|
|
29
|
+
|
|
30
|
+
Exporter for EKZ data provided on the http://my.ekz.ch customer portal.
|
|
31
|
+
|
|
32
|
+
## Installing
|
|
33
|
+
|
|
34
|
+
Get it from PyPI:
|
|
35
|
+
|
|
36
|
+
```console
|
|
37
|
+
$ python -m pip install ekzexport
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can then use the `ekzexport` CLI.
|
|
41
|
+
|
|
42
|
+
## Example Usage
|
|
43
|
+
|
|
44
|
+
To authenticate, you can either put your credentials into a JSON file
|
|
45
|
+
`ekzexport.json` in your home directory:
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"user": "myusername",
|
|
50
|
+
"password": "mypassword"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or use the `--user` and `--password` options. The following examples use a JSON
|
|
55
|
+
file.
|
|
56
|
+
|
|
57
|
+
First, list your contracts to find the installation ID of interest:
|
|
58
|
+
|
|
59
|
+
```console
|
|
60
|
+
$ ekzexport overview
|
|
61
|
+
Contracts
|
|
62
|
+
╷ ╷ ╷
|
|
63
|
+
Installation ID │ Address │ Move-in Date │ Move-out Date
|
|
64
|
+
╺━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━╸
|
|
65
|
+
123 │ Somestreet 1, 8000 Someplace │ 2010-01-01 │ 2020-01-01
|
|
66
|
+
456 │ Some Other Street 2, 8001 Otherplace │ 2020-01-02 │
|
|
67
|
+
╵ ╵ ╵
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
With the installation ID, we can then figure out what kind of data is available
|
|
71
|
+
for your account:
|
|
72
|
+
|
|
73
|
+
```console
|
|
74
|
+
$ ekzexport installation 456 properties
|
|
75
|
+
Properties
|
|
76
|
+
╷ ╷
|
|
77
|
+
Property │ From │ Until
|
|
78
|
+
╺━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━┿━━━━━━━━━━━━╸
|
|
79
|
+
CONTRACT │ 2020-01-02 │ 2024-05-01
|
|
80
|
+
SMART_METER │ 2020-01-02 │ 2024-05-01
|
|
81
|
+
VERB_15MIN │ 2020-01-02 │ 2024-05-01
|
|
82
|
+
VERB_TAG_EDM │ 2020-01-02 │ 2024-05-01
|
|
83
|
+
VERB_TAG_METER │ 2020-01-02 │ 2024-05-01
|
|
84
|
+
╵ ╵
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If you do not see any entry for 15 minute values, you likely have to enable
|
|
88
|
+
granular data on myEKZ first.
|
|
89
|
+
|
|
90
|
+
You can print consumption data to get an idea what is available:
|
|
91
|
+
|
|
92
|
+
```console
|
|
93
|
+
$ ekzexport installation 456 data --type PK_VERB_TAG_EDM --from 2024-04-01 --to 2024-04-02 show
|
|
94
|
+
Consumption Data
|
|
95
|
+
╷ ╷ ╷
|
|
96
|
+
Time │ kWh │ Tariff │ Status
|
|
97
|
+
╺━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━┿━━━━━━━━┿━━━━━━━━╸
|
|
98
|
+
2024-04-01 00:00:00 │ 12.123 │ NT │ VALID
|
|
99
|
+
2024-04-01 00:00:00 │ 10.123 │ HT │ VALID
|
|
100
|
+
2024-04-02 00:00:00 │ 12.678 │ NT │ VALID
|
|
101
|
+
2024-04-02 00:00:00 │ 8.678 │ HT │ VALID
|
|
102
|
+
╵ ╵ ╵
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
But the more interesting use-case is to export data. Available exporters are:
|
|
106
|
+
|
|
107
|
+
- `csv` to sync data to a CSV file in the same format as myEKZ offers
|
|
108
|
+
- `influxdb` to sync data to an InfluxDB 2.x server
|
|
109
|
+
|
|
110
|
+
The CLI's help command will provide further detail on the exporter-specific
|
|
111
|
+
options, for example:
|
|
112
|
+
|
|
113
|
+
```console
|
|
114
|
+
$ ekzexport installation 456 data export csv --help
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Running Exports Periodically
|
|
118
|
+
|
|
119
|
+
If you're using a Linux distribution using systemd, you can create a service
|
|
120
|
+
and trigger to run the export periodically. To do so, create
|
|
121
|
+
`/etc/systemd/system/ekzexport.service` with something like:
|
|
122
|
+
|
|
123
|
+
```ini
|
|
124
|
+
[Unit]
|
|
125
|
+
Description=Pull EKZ data
|
|
126
|
+
|
|
127
|
+
[Service]
|
|
128
|
+
Type=oneshot
|
|
129
|
+
ExecStart=/path/to/ekzexport/venv/bin/ekzexport installation 456 data export csv -f data.csv
|
|
130
|
+
WorkingDirectory=/path/to/ekzexport
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This example assumes you created a Python virtualenv to install ekzexport
|
|
134
|
+
in (which keeps the dependencies local in the venv). You can also
|
|
135
|
+
set up an `OnFailure` hook to send emails in case the export fails.
|
|
136
|
+
|
|
137
|
+
A corresponding timer can look something like this in `/etc/systemd/system/ekzexport.timer`:
|
|
138
|
+
|
|
139
|
+
```ini
|
|
140
|
+
[Unit]
|
|
141
|
+
Description=Run ekzexport once a day
|
|
142
|
+
|
|
143
|
+
[Timer]
|
|
144
|
+
OnCalendar=*-*-* 04:00:00
|
|
145
|
+
RandomizedDelaySec=30m
|
|
146
|
+
Persistent=true
|
|
147
|
+
|
|
148
|
+
[Install]
|
|
149
|
+
WantedBy=timers.target
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Please keep the randomized delay to avoid myEKZ getting a flood of requests
|
|
153
|
+
at exactly 04:00 every night. Remember to enable and start the timer.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# ekzexport
|
|
2
|
+
|
|
3
|
+
Exporter for EKZ data provided on the http://my.ekz.ch customer portal.
|
|
4
|
+
|
|
5
|
+
## Installing
|
|
6
|
+
|
|
7
|
+
Get it from PyPI:
|
|
8
|
+
|
|
9
|
+
```console
|
|
10
|
+
$ python -m pip install ekzexport
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You can then use the `ekzexport` CLI.
|
|
14
|
+
|
|
15
|
+
## Example Usage
|
|
16
|
+
|
|
17
|
+
To authenticate, you can either put your credentials into a JSON file
|
|
18
|
+
`ekzexport.json` in your home directory:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"user": "myusername",
|
|
23
|
+
"password": "mypassword"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or use the `--user` and `--password` options. The following examples use a JSON
|
|
28
|
+
file.
|
|
29
|
+
|
|
30
|
+
First, list your contracts to find the installation ID of interest:
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
$ ekzexport overview
|
|
34
|
+
Contracts
|
|
35
|
+
╷ ╷ ╷
|
|
36
|
+
Installation ID │ Address │ Move-in Date │ Move-out Date
|
|
37
|
+
╺━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━╸
|
|
38
|
+
123 │ Somestreet 1, 8000 Someplace │ 2010-01-01 │ 2020-01-01
|
|
39
|
+
456 │ Some Other Street 2, 8001 Otherplace │ 2020-01-02 │
|
|
40
|
+
╵ ╵ ╵
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
With the installation ID, we can then figure out what kind of data is available
|
|
44
|
+
for your account:
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
$ ekzexport installation 456 properties
|
|
48
|
+
Properties
|
|
49
|
+
╷ ╷
|
|
50
|
+
Property │ From │ Until
|
|
51
|
+
╺━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━┿━━━━━━━━━━━━╸
|
|
52
|
+
CONTRACT │ 2020-01-02 │ 2024-05-01
|
|
53
|
+
SMART_METER │ 2020-01-02 │ 2024-05-01
|
|
54
|
+
VERB_15MIN │ 2020-01-02 │ 2024-05-01
|
|
55
|
+
VERB_TAG_EDM │ 2020-01-02 │ 2024-05-01
|
|
56
|
+
VERB_TAG_METER │ 2020-01-02 │ 2024-05-01
|
|
57
|
+
╵ ╵
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you do not see any entry for 15 minute values, you likely have to enable
|
|
61
|
+
granular data on myEKZ first.
|
|
62
|
+
|
|
63
|
+
You can print consumption data to get an idea what is available:
|
|
64
|
+
|
|
65
|
+
```console
|
|
66
|
+
$ ekzexport installation 456 data --type PK_VERB_TAG_EDM --from 2024-04-01 --to 2024-04-02 show
|
|
67
|
+
Consumption Data
|
|
68
|
+
╷ ╷ ╷
|
|
69
|
+
Time │ kWh │ Tariff │ Status
|
|
70
|
+
╺━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━┿━━━━━━━━┿━━━━━━━━╸
|
|
71
|
+
2024-04-01 00:00:00 │ 12.123 │ NT │ VALID
|
|
72
|
+
2024-04-01 00:00:00 │ 10.123 │ HT │ VALID
|
|
73
|
+
2024-04-02 00:00:00 │ 12.678 │ NT │ VALID
|
|
74
|
+
2024-04-02 00:00:00 │ 8.678 │ HT │ VALID
|
|
75
|
+
╵ ╵ ╵
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
But the more interesting use-case is to export data. Available exporters are:
|
|
79
|
+
|
|
80
|
+
- `csv` to sync data to a CSV file in the same format as myEKZ offers
|
|
81
|
+
- `influxdb` to sync data to an InfluxDB 2.x server
|
|
82
|
+
|
|
83
|
+
The CLI's help command will provide further detail on the exporter-specific
|
|
84
|
+
options, for example:
|
|
85
|
+
|
|
86
|
+
```console
|
|
87
|
+
$ ekzexport installation 456 data export csv --help
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Running Exports Periodically
|
|
91
|
+
|
|
92
|
+
If you're using a Linux distribution using systemd, you can create a service
|
|
93
|
+
and trigger to run the export periodically. To do so, create
|
|
94
|
+
`/etc/systemd/system/ekzexport.service` with something like:
|
|
95
|
+
|
|
96
|
+
```ini
|
|
97
|
+
[Unit]
|
|
98
|
+
Description=Pull EKZ data
|
|
99
|
+
|
|
100
|
+
[Service]
|
|
101
|
+
Type=oneshot
|
|
102
|
+
ExecStart=/path/to/ekzexport/venv/bin/ekzexport installation 456 data export csv -f data.csv
|
|
103
|
+
WorkingDirectory=/path/to/ekzexport
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This example assumes you created a Python virtualenv to install ekzexport
|
|
107
|
+
in (which keeps the dependencies local in the venv). You can also
|
|
108
|
+
set up an `OnFailure` hook to send emails in case the export fails.
|
|
109
|
+
|
|
110
|
+
A corresponding timer can look something like this in `/etc/systemd/system/ekzexport.timer`:
|
|
111
|
+
|
|
112
|
+
```ini
|
|
113
|
+
[Unit]
|
|
114
|
+
Description=Run ekzexport once a day
|
|
115
|
+
|
|
116
|
+
[Timer]
|
|
117
|
+
OnCalendar=*-*-* 04:00:00
|
|
118
|
+
RandomizedDelaySec=30m
|
|
119
|
+
Persistent=true
|
|
120
|
+
|
|
121
|
+
[Install]
|
|
122
|
+
WantedBy=timers.target
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Please keep the randomized delay to avoid myEKZ getting a flood of requests
|
|
126
|
+
at exactly 04:00 every night. Remember to enable and start the timer.
|
ekzexport-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
with open('README.md', 'r', encoding='utf-8') as f:
|
|
4
|
+
readme = f.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name='ekzexport',
|
|
8
|
+
description='CLI and data exporter for the myEKZ customer portal.',
|
|
9
|
+
long_description=readme,
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
author='Manuel Stocker',
|
|
12
|
+
author_email='mensi@mensi.ch',
|
|
13
|
+
url='https://github.com/mensi/ekzexport',
|
|
14
|
+
license='Apache-2.0',
|
|
15
|
+
version='0.1.0',
|
|
16
|
+
packages=['ekzexport'],
|
|
17
|
+
package_data={'': ['LICENSE']},
|
|
18
|
+
package_dir={'': 'src'},
|
|
19
|
+
install_requires=[
|
|
20
|
+
'requests',
|
|
21
|
+
'click',
|
|
22
|
+
'beautifulsoup4',
|
|
23
|
+
'rich',
|
|
24
|
+
'platformdirs',
|
|
25
|
+
'tzdata',
|
|
26
|
+
],
|
|
27
|
+
extras_require={
|
|
28
|
+
'influx': ['influxdb-client'],
|
|
29
|
+
},
|
|
30
|
+
tests_require=[
|
|
31
|
+
'pytest',
|
|
32
|
+
],
|
|
33
|
+
entry_points={
|
|
34
|
+
'console_scripts': [
|
|
35
|
+
'ekzexport = ekzexport.cli:main',
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
classifiers=[
|
|
39
|
+
"License :: OSI Approved :: Apache Software License",
|
|
40
|
+
"Natural Language :: English",
|
|
41
|
+
"Operating System :: OS Independent",
|
|
42
|
+
"Programming Language :: Python",
|
|
43
|
+
"Programming Language :: Python :: 3.10",
|
|
44
|
+
"Programming Language :: Python :: 3.11",
|
|
45
|
+
"Programming Language :: Python :: 3.12",
|
|
46
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
47
|
+
],
|
|
48
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from typing import TypedDict, List, Optional
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Address(TypedDict):
|
|
5
|
+
addressNumber: str
|
|
6
|
+
street: str
|
|
7
|
+
houseNumber: str
|
|
8
|
+
houseNumberDetails: str
|
|
9
|
+
locationDetails: str
|
|
10
|
+
floor: str
|
|
11
|
+
postalCode: str
|
|
12
|
+
city: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ISDContract(TypedDict):
|
|
16
|
+
"""Used for the contracts property in InstallationSelectionData."""
|
|
17
|
+
gpart: str
|
|
18
|
+
vkonto: str
|
|
19
|
+
vertrag: str
|
|
20
|
+
anlage: str
|
|
21
|
+
vstelle: str
|
|
22
|
+
haus: str
|
|
23
|
+
einzdat: str
|
|
24
|
+
auszdat: Optional[str]
|
|
25
|
+
sparte: str
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ISDAnlage(TypedDict):
|
|
29
|
+
"""Used for the eanl property in InstallationSelectionData."""
|
|
30
|
+
anlage: str
|
|
31
|
+
sparte: str
|
|
32
|
+
vstelle: str
|
|
33
|
+
anlart: str
|
|
34
|
+
spebene: str
|
|
35
|
+
zzenergietraeger: Optional[str]
|
|
36
|
+
zzevgstat: Optional[str]
|
|
37
|
+
zzevganlage: Optional[str]
|
|
38
|
+
eanlhTariftyp: str
|
|
39
|
+
eanlhAbleinh: str
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ISDStelle(TypedDict):
|
|
43
|
+
vstelle: str
|
|
44
|
+
haus: str
|
|
45
|
+
eigent: str
|
|
46
|
+
vbsart: str
|
|
47
|
+
lgzusatz: str
|
|
48
|
+
floor: str
|
|
49
|
+
zzlage: str
|
|
50
|
+
zzlgzusatz: str
|
|
51
|
+
iflotZzanobjart: str
|
|
52
|
+
iflotZzeigen: str
|
|
53
|
+
iflotZzegid: str
|
|
54
|
+
address: Address
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ISDFkkVkp(TypedDict):
|
|
58
|
+
vkont: str
|
|
59
|
+
gpart: str
|
|
60
|
+
opbuk: str
|
|
61
|
+
stdbk: str
|
|
62
|
+
abrwe: Optional[str]
|
|
63
|
+
abwra: Optional[str]
|
|
64
|
+
abwma: Optional[str]
|
|
65
|
+
ebvty: Optional[str]
|
|
66
|
+
abvty: str
|
|
67
|
+
ezawe: str
|
|
68
|
+
azawe: str
|
|
69
|
+
vkpbz: str
|
|
70
|
+
ktokl: str
|
|
71
|
+
consolidatorId: str
|
|
72
|
+
zzRechDet: str
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class InstallationSelectionData(TypedDict):
|
|
76
|
+
"""Return schema for /consumption-view/v1/installation-selection-data?installationVariant=CONSUMPTION"""
|
|
77
|
+
contracts: List[ISDContract]
|
|
78
|
+
eanl: List[ISDAnlage]
|
|
79
|
+
evbs: List[ISDStelle]
|
|
80
|
+
fkkvkp: List[ISDFkkVkp]
|
|
81
|
+
commonData: Optional[str]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class IDProperty(TypedDict):
|
|
85
|
+
property: str
|
|
86
|
+
ab: str
|
|
87
|
+
bis: str
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class InstallationData(TypedDict):
|
|
91
|
+
"""Return schema for /consumption-view/v1/installation-data?installationId=..."""
|
|
92
|
+
status: List[IDProperty]
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Value(TypedDict):
|
|
96
|
+
value: float
|
|
97
|
+
timestamp: int
|
|
98
|
+
date: str
|
|
99
|
+
time: str
|
|
100
|
+
status: str
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class Series(TypedDict):
|
|
104
|
+
level: str
|
|
105
|
+
energyType: Optional[str]
|
|
106
|
+
sourceType: Optional[str]
|
|
107
|
+
tariffType: str
|
|
108
|
+
ab: str
|
|
109
|
+
bis: str
|
|
110
|
+
values: List[Value]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class ConsumptionData(TypedDict):
|
|
114
|
+
"""Return schema for /consumption-view/v1/consumption-data?installationId=..."""
|
|
115
|
+
series: Optional[Series]
|
|
116
|
+
seriesHt: Optional[Series]
|
|
117
|
+
seriesNetz: Optional[Series]
|
|
118
|
+
seriesNetzHt: Optional[Series]
|
|
119
|
+
seriesNetzHt: Optional[Series]
|
|
120
|
+
seriesNt: Optional[Series]
|