enovapower 0.5.1__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.
@@ -0,0 +1,2 @@
1
+ ENOVA_USERNAME=your_username
2
+ ENOVA_PASSWORD=your_password
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "pip"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ groups:
8
+ python-dependencies:
9
+ patterns:
10
+ - "*"
11
+
12
+ - package-ecosystem: "github-actions"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "weekly"
@@ -0,0 +1,56 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Lint
28
+ run: ruff check enovapower/ tests/
29
+
30
+ - name: Type check
31
+ run: mypy
32
+
33
+ - name: Test
34
+ run: pytest tests/ -v
35
+
36
+ audit:
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+
41
+ - name: Set up Python
42
+ uses: actions/setup-python@v5
43
+ with:
44
+ python-version: "3.12"
45
+
46
+ - name: Install dependencies
47
+ # Only the runtime deps (no dev tooling): those are what ship to users.
48
+ run: |
49
+ python -m pip install --upgrade pip setuptools
50
+ python -m pip install -e . pip-audit
51
+
52
+ - name: Audit dependencies for known vulnerabilities
53
+ # Skip the editable-installed project itself (enovapower isn't on PyPI
54
+ # while developing). --strict can't be combined with --skip-editable
55
+ # because it treats the skipped project as a failure.
56
+ run: pip-audit --skip-editable
@@ -0,0 +1,44 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch: {}
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: "3.12"
18
+
19
+ - name: Build sdist and wheel
20
+ run: pipx run build
21
+
22
+ - name: Check metadata
23
+ run: pipx run twine check dist/*
24
+
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: dist
28
+ path: dist/
29
+
30
+ publish:
31
+ needs: build
32
+ runs-on: ubuntu-latest
33
+ # Matches the environment configured on the PyPI trusted publisher.
34
+ environment: pypi
35
+ permissions:
36
+ id-token: write # required for PyPI Trusted Publishing (OIDC); no token needed
37
+ steps:
38
+ - uses: actions/download-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+
43
+ - name: Publish to PyPI
44
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .env
8
+ *.db
9
+ .DS_Store
10
+ .pytest_cache/
11
+ .ruff_cache/
@@ -0,0 +1,105 @@
1
+ # Changelog
2
+
3
+ ## 0.5.1
4
+
5
+ ### Security
6
+
7
+ - Raised the minimum `aiohttp` to `>=3.14.1` to exclude versions affected by the
8
+ 2026 client-side CVEs (fixed in aiohttp 3.14.0/3.14.1).
9
+
10
+ ## 0.5.0
11
+
12
+ ### Added
13
+
14
+ - `UsageReading.intervals()` returns hourly values as `(interval_start, kWh)`
15
+ pairs with **timezone-aware** timestamps (UTC by default, configurable),
16
+ mapping each hour from fixed Eastern Standard Time. This is the recommended
17
+ way to feed a time-series store or the Home Assistant statistics engine.
18
+ - `EASTERN_STANDARD` timezone constant documenting the portal's fixed-offset
19
+ (UTC-5, no DST) time basis.
20
+ - `parse_green_button_xml()` parses Green Button (ESPI) XML exports into
21
+ `GreenButtonInterval` objects (UTC start, duration, kWh), using `defusedxml`
22
+ for safe parsing.
23
+ - Multi-meter support: `meter_ids` property lists every meter on the account
24
+ and `select_meter()` switches the active meter (both clients).
25
+ - `reauth_callback` parameter on `AsyncEnovaClient` to drive re-authentication
26
+ through caller-supplied credentials instead of retaining a password.
27
+
28
+ ### Changed
29
+
30
+ - Re-login on session expiry is now serialized (an `asyncio.Lock` plus a login
31
+ generation counter), so concurrent expired requests don't all re-authenticate.
32
+
33
+ - **Missing vs. zero:** an hour the portal does not report now parses to
34
+ `None` instead of `0.0`, so genuine gaps are distinguishable from real
35
+ zero-consumption hours. `UsageReading.hourly` is now typed
36
+ `dict[str, float | None]`, `total` sums only present hours, and the SQLite
37
+ store persists missing hours as `NULL`.
38
+ - `parse_csv` now raises `EnovaError` (instead of a bare `ValueError`) on an
39
+ unparseable reading date; tariff parsing does the same for heading dates.
40
+ - `get_latest_usage()` selects the most recent reading by date rather than by
41
+ list position.
42
+ - Minimum `aiohttp` raised to `>=3.10.11` to clear known client-side CVEs.
43
+
44
+ ### Security
45
+
46
+ - `UsageStore` restricts its database file to owner-only (`0600`) — hourly
47
+ usage reveals household occupancy patterns.
48
+ - HTTP responses are capped at 64 MB to bound memory against a misbehaving or
49
+ spoofed endpoint.
50
+ - `meter_id` is no longer logged at INFO (moved to DEBUG).
51
+ - Green Button XML is parsed with `defusedxml`, blocking entity-expansion attacks.
52
+ - CI now runs `pip-audit` and `mypy --strict`; added Dependabot for dependencies
53
+ and Actions. The package now type-checks clean under `mypy --strict`.
54
+
55
+ ## 0.4.0
56
+
57
+ ### Added
58
+
59
+ - Built-in logging support using Python's standard `logging` module.
60
+ - `logger` parameter on `AsyncEnovaClient` and `UsageStore` for custom logger injection.
61
+ - `get_logger()` function to access the library logger.
62
+ - `configure_logging()` function for easy default configuration.
63
+ - Logging at key operations: login, downloads, session expiry, retries, database operations.
64
+ - Comprehensive test coverage for logging functionality.
65
+
66
+ ### Changed
67
+
68
+ - `AsyncEnovaClient` and `UsageStore` now use instance-level loggers instead of module-level.
69
+
70
+ ## 0.3.0 (unreleased)
71
+
72
+ ### Breaking changes
73
+
74
+ - Renamed `EnovaConnectionError` to `EnovaNetworkError` to avoid shadowing Python's builtin `ConnectionError`.
75
+
76
+ ### Added
77
+
78
+ - Apache-2.0 license.
79
+ - `__version__` attribute exported from the package.
80
+ - Configurable `base_url` parameter on both clients.
81
+ - Connection timeout (30s) on internally-created `aiohttp` sessions.
82
+ - User-Agent header is now applied to externally-provided sessions.
83
+ - `UsageReading.__post_init__` auto-computes `total` from hourly values when not explicitly set.
84
+ - Custom `__repr__` on `UsageReading` and `TariffRate` for cleaner logging.
85
+ - Parsers now raise `EnovaError` on empty or malformed input instead of returning `[]`.
86
+ - GitHub Actions CI workflow (lint + test on Python 3.10-3.12).
87
+ - `CHANGELOG.md`.
88
+
89
+ ### Fixed
90
+
91
+ - Sync `EnovaClient` now works inside an existing event loop (e.g. Home Assistant) by using a background-thread event loop instead of `asyncio.run()`.
92
+ - Complete PyPI metadata (`authors`, `license`, `readme`, `urls`, `classifiers`, `build-system`).
93
+ - `py.typed` marker is now included in wheel builds.
94
+
95
+ ## 0.2.0
96
+
97
+ - Async-first architecture with `AsyncEnovaClient` and sync `EnovaClient` facade.
98
+ - Retry logic with exponential backoff.
99
+ - Automatic session expiry detection and re-login.
100
+ - SQLite storage layer with `UsageStore`.
101
+ - Tariff rate collection for all pricing plans.
102
+
103
+ ## 0.1.0
104
+
105
+ - Initial release with synchronous client only.
@@ -0,0 +1,32 @@
1
+ # Contributing
2
+
3
+ ## Setup
4
+
5
+ Using [uv](https://docs.astral.sh/uv/) (recommended):
6
+ ```bash
7
+ uv sync --extra dev
8
+ make install-hooks
9
+ ```
10
+
11
+ Using pip:
12
+ ```bash
13
+ python3 -m venv .venv
14
+ source .venv/bin/activate
15
+ pip install -e ".[dev]"
16
+ make install-hooks
17
+ ```
18
+
19
+ ## Development workflow
20
+
21
+ Before every commit, linting and tests must pass. The pre-commit hook enforces this automatically, but you can also run checks manually:
22
+
23
+ ```bash
24
+ make check # run both lint + tests
25
+ make lint # ruff only
26
+ make test # pytest only
27
+ ```
28
+
29
+ ## Tools
30
+
31
+ - **Linter**: [ruff](https://docs.astral.sh/ruff/) — configured in `pyproject.toml`
32
+ - **Tests**: [pytest](https://docs.pytest.org/) — test files live in `tests/`
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Hani Hawari
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,15 @@
1
+ .PHONY: lint test check install-hooks
2
+
3
+ lint:
4
+ uv tool run ruff check .
5
+
6
+ test:
7
+ .venv/bin/python -m pytest tests/ -v
8
+
9
+ check: lint test
10
+
11
+ install-hooks:
12
+ @echo "Installing pre-commit hook..."
13
+ @cp hooks/pre-commit .git/hooks/pre-commit
14
+ @chmod +x .git/hooks/pre-commit
15
+ @echo "Done."
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: enovapower
3
+ Version: 0.5.1
4
+ Summary: Python client for downloading electricity usage data from Enova Power
5
+ Project-URL: Homepage, https://github.com/hanihawari/enovapower
6
+ Project-URL: Repository, https://github.com/hanihawari/enovapower
7
+ Project-URL: Issues, https://github.com/hanihawari/enovapower/issues
8
+ Author: Hani Hawari
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Home Automation
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: aiohttp>=3.14.1
23
+ Requires-Dist: beautifulsoup4>=4.12
24
+ Requires-Dist: defusedxml>=0.7
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.8; extra == 'dev'
27
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.4; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # enovapower
33
+
34
+ > **⚠️ Unofficial project — not affiliated with, endorsed by, or supported by Enova Power Corp.** "Enova Power" is a trademark of its respective owner. Use at your own risk under the Apache-2.0 license.
35
+
36
+ A Python library for downloading electricity usage data from the [Enova Power](https://enovapower.com) customer portal.
37
+
38
+ Enova Power serves residential and commercial customers in the Kitchener-Waterloo region of Ontario, Canada. Their My Account portal provides smart meter data exports, but only through a web UI. This library automates that process so you can pull your usage data into scripts, notebooks, dashboards, or data pipelines.
39
+
40
+ ## Quick start
41
+
42
+ ### Install
43
+
44
+ Using [uv](https://docs.astral.sh/uv/) (recommended):
45
+ ```
46
+ uv add enovapower
47
+ ```
48
+
49
+ Using pip:
50
+ ```bash
51
+ pip install enovapower
52
+ ```
53
+
54
+ ### Environment variables
55
+
56
+ Credentials can be set via environment variables instead of passing them directly:
57
+
58
+ ```bash
59
+ export ENOVA_USERNAME="user@example.com"
60
+ export ENOVA_PASSWORD="your_password"
61
+ ```
62
+
63
+ ### Async client (primary)
64
+
65
+ The `AsyncEnovaClient` is the primary interface.
66
+
67
+ ```python
68
+ from datetime import date
69
+ from enovapower import AsyncEnovaClient
70
+
71
+ async with AsyncEnovaClient() as client:
72
+ await client.login("user@example.com", "your_password") # Do not pass credentials if they are set via environment variables
73
+ readings = await client.download_usage(date(2026, 2, 25), date(2026, 3, 26))
74
+ for r in readings:
75
+ print(f"{r.date}: {r.total:.2f} kWh")
76
+ ```
77
+
78
+ ### Sync client (convenience)
79
+
80
+ The `EnovaClient` is a thin synchronous wrapper for scripts and non-async contexts. It runs a dedicated background event loop.
81
+
82
+ ```python
83
+ from datetime import date
84
+ from enovapower import EnovaClient
85
+
86
+ client = EnovaClient()
87
+ client.login("user@example.com", "your_password")
88
+
89
+ readings = client.download_usage(date(2026, 2, 25), date(2026, 3, 26))
90
+ for r in readings:
91
+ print(f"{r.date}: {r.total:.2f} kWh")
92
+ ```
93
+
94
+ ## Features
95
+
96
+ - Authenticate with the Enova Power My Account portal
97
+ - Download hourly smart meter usage data as `UsageReading` dataclasses
98
+ - Convert hourly readings to timezone-aware UTC `(timestamp, kWh)` intervals via `UsageReading.intervals()`
99
+ - Distinguish missing hours (`None`) from real zero-consumption hours
100
+ - Download Green Button XML exports and parse them with `parse_green_button_xml()` (safe `defusedxml` parsing)
101
+ - Multi-meter accounts via `meter_ids` / `select_meter()`
102
+ - Optional re-authentication callback to avoid retaining credentials
103
+ - Download tariff rates for all pricing plans (Time-of-Use, Ultra-Low Overnight, Tiered)
104
+ - Automatically chunk requests for date ranges exceeding 90 days
105
+ - Store and incrementally update usage history in a local SQLite database
106
+ - Automatic retry with exponential backoff on transient errors
107
+ - Session expiry detection with automatic re-login
108
+ - Configurable `base_url` for custom portal endpoints
109
+ - Built-in logging with customizable logger support
110
+
111
+ ## Local storage
112
+
113
+ ```python
114
+ from enovapower import EnovaClient, UsageStore
115
+
116
+ client = EnovaClient()
117
+ client.login("user@example.com", "your_password")
118
+
119
+ with UsageStore("usage.db") as store:
120
+ store.seed(client, months=12) # initial backfill
121
+ store.update(client) # incremental update
122
+ readings = store.load("111111", from_date, to_date)
123
+ ```
124
+
125
+ ## Polling interval
126
+
127
+ The Enova portal is a utility web UI, not a high-throughput API. Avoid polling more frequently than every 15 minutes. A 30-minute interval is recommended for regular updates.
128
+
129
+ ## Logging
130
+
131
+ The library uses Python's standard `logging` module. The logger name is `"enovapower"`.
132
+
133
+ ### Basic usage
134
+
135
+ ```python
136
+ import logging
137
+
138
+ logging.basicConfig(level=logging.DEBUG)
139
+ # Now all enovapower logs will appear
140
+ ```
141
+
142
+ ### Custom logger
143
+
144
+ You can inject a custom logger to both clients and storage:
145
+
146
+ ```python
147
+ import logging
148
+
149
+ my_logger = logging.getLogger("my_app")
150
+ my_logger.setLevel(logging.INFO)
151
+
152
+ client = AsyncEnovaClient(logger=my_logger)
153
+ store = UsageStore("usage.db", logger=my_logger)
154
+ ```
155
+
156
+ ### Built-in configuration
157
+
158
+ The library provides a convenience function to set up default handlers:
159
+
160
+ ```python
161
+ from enovapower.logger import configure_logging
162
+
163
+ # Configure with default format and DEBUG level
164
+ configure_logging(level=logging.DEBUG)
165
+
166
+ # Or with custom format
167
+ configure_logging(
168
+ level=logging.INFO,
169
+ format_string="%(asctime)s - %(levelname)s - %(message)s"
170
+ )
171
+ ```
172
+
173
+ ## Security
174
+
175
+ Credentials passed to `login()` are stored in memory to enable automatic re-authentication on session expiry. They are never written to disk.
176
+
177
+ The library requires HTTPS by default. Use `allow_insecure_http=True` only for local testing against a development endpoint.
178
+
179
+ `UsageStore` databases are created with owner-only permissions (`0600`), since hourly usage data can reveal household occupancy patterns.
180
+
181
+ ## Documentation
182
+
183
+ See [docs/usage.md](docs/usage.md) for detailed API documentation and examples.
184
+
185
+ ## Development
186
+
187
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions and development workflow.
188
+
189
+ ## License
190
+
191
+ Apache-2.0. See [LICENSE](LICENSE) for details.