pynortecgo 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.
@@ -0,0 +1,30 @@
1
+ # Secrets
2
+ .env
3
+
4
+ # Local capture data
5
+ captures/
6
+ local/
7
+ *.har
8
+ *.flows
9
+
10
+ # Python
11
+ __pycache__/
12
+ *.pyc
13
+ .venv/
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+
18
+ # macOS
19
+ .DS_Store
20
+
21
+ # build
22
+ *.egg-info/
23
+ build/
24
+ dist/
25
+
26
+ # Local tool environments and artifacts
27
+ .venv-tools/
28
+ *.token
29
+ .monta_token
30
+ tools/**/*.apk
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ All notable changes to `pynortecgo` are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-09-26
10
+
11
+ First release on PyPI.
12
+
13
+ ### Changed
14
+ - Package renamed from `montaclient` to `pynortecgo`; `src/` layout; built with hatchling, managed with uv.
15
+ - Requires Python 3.13+.
16
+ - The client is rewritten: `NortecGoClient` replaces `MontaClient`, with new models, enums and exceptions.
17
+ The old methods and models are gone.
18
+
19
+ ### Added
20
+ - `py.typed` marker (the package is fully typed and checked with `mypy --strict`).
21
+ - `login()`, with token refresh on 401 (one refresh at a time; a rejected refresh isn't repeated) and an `on_tokens_refreshed` callback.
22
+ - `get_charger()`: state and whether a cable is connected.
23
+ - `get_vehicle()`: battery level, plugged in, charge limit, last seen.
24
+ - `get_price_forecast()`: 15-minute price slots for about 7 days; the price zone defaults to the charger's.
25
+ - Retries on rate limits, network errors and 502/503/504 (`RetryPolicy`); depends on `tenacity`.
26
+ - `Charger.charge_state` and `Charger.charge_state_raw`, read from the charger's active charge; the new
27
+ `ChargeState` enum.
28
+ - `ChargerState.BUSY`, `BUSY_CHARGING` and `BUSY_NON_RELEASED`.
29
+ - `start_charge()` and `stop_charge()`, returning the new `Charge`; `Charger.charge_id` and
30
+ `Charger.can_stop`. Charge requests are never retried.
31
+ - `ChargeStartError` (with `ChargeStartStep`), `ChargeAlreadyActiveError`, `CableNotConnectedError`,
32
+ `ChargerNotReleasedError`, `PaymentSourceNotFoundError`, `MultiplePaymentSourcesError`,
33
+ `NoActiveChargeError`, `ChargeNotStoppableError`.
34
+
35
+ ### Removed
36
+ - `Charger.is_charging` and `Vehicle.is_charging`: use `Charger.charge_state`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 thomas3650
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,123 @@
1
+ Metadata-Version: 2.5
2
+ Name: pynortecgo
3
+ Version: 0.1.0
4
+ Summary: Unofficial async client for the Monta API used by the Nortec Go app
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Framework :: AsyncIO
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Topic :: Home Automation
14
+ Classifier: Typing :: Typed
15
+ Requires-Python: >=3.13
16
+ Requires-Dist: aiohttp>=3.9
17
+ Requires-Dist: tenacity>=8.2
18
+ Description-Content-Type: text/markdown
19
+
20
+ # pynortecgo
21
+
22
+ Unofficial async Python client for the Monta API used by the **Nortec Go** app (a white-label Monta app).
23
+ Built to power a Home Assistant integration, so a Nortec Go charger can be driven by tools such as
24
+ [ev_smart_charging](https://github.com/jonasbkarlsson/ev_smart_charging).
25
+
26
+ > **Unofficial.** Not affiliated with, endorsed by or supported by Nortec or Monta. It uses the same private
27
+ > API as the app, which can change without notice.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install pynortecgo
33
+ ```
34
+
35
+ Requires Python 3.13+.
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ import asyncio
41
+
42
+ import aiohttp
43
+ from pynortecgo import NortecGoClient
44
+
45
+
46
+ async def main() -> None:
47
+ async with aiohttp.ClientSession() as session:
48
+ client = NortecGoClient(session)
49
+ tokens = await client.login("you@example.com", "password") # store tokens and client.device_id
50
+ charger = await client.get_charger()
51
+ vehicle = await client.get_vehicle()
52
+ forecast = await client.get_price_forecast()
53
+ print(
54
+ charger.state,
55
+ charger.is_connected,
56
+ charger.charge_state,
57
+ vehicle.battery_level,
58
+ forecast.slots[0],
59
+ )
60
+
61
+
62
+ asyncio.run(main())
63
+ ```
64
+
65
+ - **Log in once.** Login is rate-limited. Store the returned `Tokens` and `client.device_id`, and pass them
66
+ to the next client: `NortecGoClient(session, tokens=tokens, device_id=device_id,
67
+ on_tokens_refreshed=save)`. The client refreshes the token on a 401 and calls `on_tokens_refreshed`.
68
+ `on_tokens_refreshed` must be an async function that takes the new `Tokens`, e.g.
69
+ `async def save(tokens: Tokens) -> None`. `on_tokens_refreshed` must not call the client.
70
+ - **The session is yours.** The client never closes it, so Home Assistant can share its own.
71
+ - **One charger and one car.** `get_charger()` and `get_vehicle()` raise if the account has none or more
72
+ than one.
73
+ - **Car data can be old.** It comes from the car's own integration and can lag by hours; check
74
+ `Vehicle.last_seen`. `Charger.is_connected` comes from the charger and is live. For whether the car is
75
+ charging, read `Charger.charge_state`, which comes from the charger's open charge; the car's own
76
+ `power_delivery_state` can stay "stopped" during a charge. `ChargeState.CHARGING` is assumed to mean the
77
+ car is drawing power; whether the charge leaves that state when the car stops at its own limit hasn't
78
+ been seen yet.
79
+ - **Charging states.** `Charger.charge_state` is the open charge's state (`ChargeState`), `None` when no
80
+ charge is open; `Charger.charge_id` and `Charger.can_stop` belong to that charge.
81
+ `ChargerState.BUSY_CHARGING` alone doesn't mean power is flowing.
82
+ - **Starting and stopping.** `start_charge()` places a real card hold and starts a real charge on the
83
+ account's one charger, paid with the account's one saved card. It refuses when a charge is in progress, no
84
+ cable is connected, or the charger still holds the last charge (unplug and replug the cable first). Its
85
+ requests are never retried, and **you must not retry it automatically either**:
86
+ each attempt can place a new card hold. A failure after the first payment request raises
87
+ `ChargeStartError`, whose `step` and `hold_may_be_placed` say how far it got. `stop_charge()` stops the
88
+ charge in progress. Both return the charge as the API answered, before it has finished starting or
89
+ stopping, so read the charger to follow it.
90
+ - **Prices** are 15-minute slots from the current hour to about 7 days ahead: the spot price incl. VAT per
91
+ kWh, without fees or grid tariff. `country_area_id` is the price zone (bidding area); `2` is DK East
92
+ (DK2), the only value observed so far. Omit it to use the price zone of the account's one charger (that
93
+ reads the charger, so it can raise the charger errors).
94
+ - **Errors** are `NortecGoError` subclasses: `AuthError`, `RateLimitError`, `NortecGoConnectionError`,
95
+ `ApiError`, `UnexpectedResponseError` (the private API changed), `ChargerNotFoundError`,
96
+ `MultipleChargersError`, `VehicleNotFoundError`, `MultipleVehiclesError`, `ChargeAlreadyActiveError`,
97
+ `CableNotConnectedError`, `PaymentSourceNotFoundError`, `MultiplePaymentSourcesError`,
98
+ `ChargeStartError`, `NoActiveChargeError`, `ChargeNotStoppableError`, `ChargerNotReleasedError`.
99
+ - **Retries** on rate limits, network errors and 502/503/504 are built in; tune them with the `retry=`
100
+ argument (`RetryPolicy`). Starting and stopping a charge is the exception: those requests are sent once.
101
+
102
+ ## Client status
103
+
104
+ Alpha.
105
+
106
+ | Feature | Status |
107
+ |---|---|
108
+ | Login, token refresh | done |
109
+ | Charger: state, cable connected | done |
110
+ | Charger: charging or not | done |
111
+ | Car: battery, plugged in, last seen | done |
112
+ | Price forecast in 15-minute slots | done |
113
+ | Start / stop charging | done |
114
+
115
+ ## Development
116
+
117
+ ```bash
118
+ uv sync && uv run pytest -q
119
+ ```
120
+
121
+ ## License
122
+
123
+ MIT
@@ -0,0 +1,104 @@
1
+ # pynortecgo
2
+
3
+ Unofficial async Python client for the Monta API used by the **Nortec Go** app (a white-label Monta app).
4
+ Built to power a Home Assistant integration, so a Nortec Go charger can be driven by tools such as
5
+ [ev_smart_charging](https://github.com/jonasbkarlsson/ev_smart_charging).
6
+
7
+ > **Unofficial.** Not affiliated with, endorsed by or supported by Nortec or Monta. It uses the same private
8
+ > API as the app, which can change without notice.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install pynortecgo
14
+ ```
15
+
16
+ Requires Python 3.13+.
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ import asyncio
22
+
23
+ import aiohttp
24
+ from pynortecgo import NortecGoClient
25
+
26
+
27
+ async def main() -> None:
28
+ async with aiohttp.ClientSession() as session:
29
+ client = NortecGoClient(session)
30
+ tokens = await client.login("you@example.com", "password") # store tokens and client.device_id
31
+ charger = await client.get_charger()
32
+ vehicle = await client.get_vehicle()
33
+ forecast = await client.get_price_forecast()
34
+ print(
35
+ charger.state,
36
+ charger.is_connected,
37
+ charger.charge_state,
38
+ vehicle.battery_level,
39
+ forecast.slots[0],
40
+ )
41
+
42
+
43
+ asyncio.run(main())
44
+ ```
45
+
46
+ - **Log in once.** Login is rate-limited. Store the returned `Tokens` and `client.device_id`, and pass them
47
+ to the next client: `NortecGoClient(session, tokens=tokens, device_id=device_id,
48
+ on_tokens_refreshed=save)`. The client refreshes the token on a 401 and calls `on_tokens_refreshed`.
49
+ `on_tokens_refreshed` must be an async function that takes the new `Tokens`, e.g.
50
+ `async def save(tokens: Tokens) -> None`. `on_tokens_refreshed` must not call the client.
51
+ - **The session is yours.** The client never closes it, so Home Assistant can share its own.
52
+ - **One charger and one car.** `get_charger()` and `get_vehicle()` raise if the account has none or more
53
+ than one.
54
+ - **Car data can be old.** It comes from the car's own integration and can lag by hours; check
55
+ `Vehicle.last_seen`. `Charger.is_connected` comes from the charger and is live. For whether the car is
56
+ charging, read `Charger.charge_state`, which comes from the charger's open charge; the car's own
57
+ `power_delivery_state` can stay "stopped" during a charge. `ChargeState.CHARGING` is assumed to mean the
58
+ car is drawing power; whether the charge leaves that state when the car stops at its own limit hasn't
59
+ been seen yet.
60
+ - **Charging states.** `Charger.charge_state` is the open charge's state (`ChargeState`), `None` when no
61
+ charge is open; `Charger.charge_id` and `Charger.can_stop` belong to that charge.
62
+ `ChargerState.BUSY_CHARGING` alone doesn't mean power is flowing.
63
+ - **Starting and stopping.** `start_charge()` places a real card hold and starts a real charge on the
64
+ account's one charger, paid with the account's one saved card. It refuses when a charge is in progress, no
65
+ cable is connected, or the charger still holds the last charge (unplug and replug the cable first). Its
66
+ requests are never retried, and **you must not retry it automatically either**:
67
+ each attempt can place a new card hold. A failure after the first payment request raises
68
+ `ChargeStartError`, whose `step` and `hold_may_be_placed` say how far it got. `stop_charge()` stops the
69
+ charge in progress. Both return the charge as the API answered, before it has finished starting or
70
+ stopping, so read the charger to follow it.
71
+ - **Prices** are 15-minute slots from the current hour to about 7 days ahead: the spot price incl. VAT per
72
+ kWh, without fees or grid tariff. `country_area_id` is the price zone (bidding area); `2` is DK East
73
+ (DK2), the only value observed so far. Omit it to use the price zone of the account's one charger (that
74
+ reads the charger, so it can raise the charger errors).
75
+ - **Errors** are `NortecGoError` subclasses: `AuthError`, `RateLimitError`, `NortecGoConnectionError`,
76
+ `ApiError`, `UnexpectedResponseError` (the private API changed), `ChargerNotFoundError`,
77
+ `MultipleChargersError`, `VehicleNotFoundError`, `MultipleVehiclesError`, `ChargeAlreadyActiveError`,
78
+ `CableNotConnectedError`, `PaymentSourceNotFoundError`, `MultiplePaymentSourcesError`,
79
+ `ChargeStartError`, `NoActiveChargeError`, `ChargeNotStoppableError`, `ChargerNotReleasedError`.
80
+ - **Retries** on rate limits, network errors and 502/503/504 are built in; tune them with the `retry=`
81
+ argument (`RetryPolicy`). Starting and stopping a charge is the exception: those requests are sent once.
82
+
83
+ ## Client status
84
+
85
+ Alpha.
86
+
87
+ | Feature | Status |
88
+ |---|---|
89
+ | Login, token refresh | done |
90
+ | Charger: state, cable connected | done |
91
+ | Charger: charging or not | done |
92
+ | Car: battery, plugged in, last seen | done |
93
+ | Price forecast in 15-minute slots | done |
94
+ | Start / stop charging | done |
95
+
96
+ ## Development
97
+
98
+ ```bash
99
+ uv sync && uv run pytest -q
100
+ ```
101
+
102
+ ## License
103
+
104
+ MIT
@@ -0,0 +1,62 @@
1
+ [project]
2
+ name = "pynortecgo"
3
+ version = "0.1.0"
4
+ description = "Unofficial async client for the Monta API used by the Nortec Go app"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.13"
9
+ dependencies = [
10
+ "aiohttp>=3.9",
11
+ "tenacity>=8.2",
12
+ ]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Framework :: AsyncIO",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Home Automation",
21
+ "Typing :: Typed",
22
+ ]
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "pytest>=8",
27
+ "pytest-asyncio>=0.23",
28
+ "ruff>=0.6",
29
+ "mypy>=1.11",
30
+ "pre-commit>=3.8",
31
+ "questionary>=2.1.1",
32
+ "rich>=15.0.0",
33
+ ]
34
+
35
+ [build-system]
36
+ requires = ["hatchling>=1.26"]
37
+ build-backend = "hatchling.build"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/pynortecgo"]
41
+
42
+ [tool.hatch.build.targets.sdist]
43
+ only-include = ["src/pynortecgo", "README.md", "LICENSE", "CHANGELOG.md"]
44
+
45
+ [tool.ruff]
46
+ target-version = "py313"
47
+ line-length = 100
48
+ src = ["src", "tests"]
49
+ extend-exclude = ["*.md"]
50
+ per-file-target-version = {".claude/hooks/*.py" = "py39"}
51
+
52
+ [tool.ruff.lint]
53
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF", "ASYNC", "PYI", "FURB", "FA"]
54
+ ignore = ["E501"] # the formatter owns line length; long strings/URLs are allowed
55
+
56
+ [tool.mypy]
57
+ strict = true
58
+ files = ["src"]
59
+
60
+ [tool.pytest.ini_options]
61
+ asyncio_mode = "auto"
62
+ testpaths = ["tests"]
@@ -0,0 +1,73 @@
1
+ """pynortecgo — async client for the private Monta API used by the Nortec Go app."""
2
+
3
+ from importlib.metadata import version as _version
4
+
5
+ from ._http import RetryPolicy
6
+ from .client import NortecGoClient
7
+ from .exceptions import (
8
+ ApiError,
9
+ AuthError,
10
+ CableNotConnectedError,
11
+ ChargeAlreadyActiveError,
12
+ ChargeNotStoppableError,
13
+ ChargerNotFoundError,
14
+ ChargerNotReleasedError,
15
+ ChargeStartError,
16
+ ChargeStartStep,
17
+ MultipleChargersError,
18
+ MultiplePaymentSourcesError,
19
+ MultipleVehiclesError,
20
+ NoActiveChargeError,
21
+ NortecGoConnectionError,
22
+ NortecGoError,
23
+ PaymentSourceNotFoundError,
24
+ RateLimitError,
25
+ UnexpectedResponseError,
26
+ VehicleNotFoundError,
27
+ )
28
+ from .models import (
29
+ Charge,
30
+ Charger,
31
+ ChargerState,
32
+ ChargeState,
33
+ PowerDeliveryState,
34
+ PriceForecast,
35
+ PriceSlot,
36
+ Tokens,
37
+ Vehicle,
38
+ )
39
+
40
+ __all__ = [
41
+ "ApiError",
42
+ "AuthError",
43
+ "CableNotConnectedError",
44
+ "Charge",
45
+ "ChargeAlreadyActiveError",
46
+ "ChargeNotStoppableError",
47
+ "ChargeStartError",
48
+ "ChargeStartStep",
49
+ "ChargeState",
50
+ "Charger",
51
+ "ChargerNotFoundError",
52
+ "ChargerNotReleasedError",
53
+ "ChargerState",
54
+ "MultipleChargersError",
55
+ "MultiplePaymentSourcesError",
56
+ "MultipleVehiclesError",
57
+ "NoActiveChargeError",
58
+ "NortecGoClient",
59
+ "NortecGoConnectionError",
60
+ "NortecGoError",
61
+ "PaymentSourceNotFoundError",
62
+ "PowerDeliveryState",
63
+ "PriceForecast",
64
+ "PriceSlot",
65
+ "RateLimitError",
66
+ "RetryPolicy",
67
+ "Tokens",
68
+ "UnexpectedResponseError",
69
+ "Vehicle",
70
+ "VehicleNotFoundError",
71
+ ]
72
+
73
+ __version__ = _version("pynortecgo")