pytouchlinesl 0.2.0__tar.gz → 0.4.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.
- {pytouchlinesl-0.2.0/pytouchlinesl.egg-info → pytouchlinesl-0.4.0}/PKG-INFO +15 -3
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/README.md +11 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pyproject.toml +2 -2
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/client/client.py +6 -15
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/client/models/models.py +2 -5
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/module.py +9 -10
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/touchlinesl.py +11 -4
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0/pytouchlinesl.egg-info}/PKG-INFO +15 -3
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl.egg-info/requires.txt +1 -1
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/tests/test_module.py +20 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/tests/test_touchlinesl.py +9 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/LICENSE +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/__init__.py +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/client/__init__.py +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/client/base.py +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/client/models/__init__.py +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl/zone.py +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl.egg-info/SOURCES.txt +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl.egg-info/dependency_links.txt +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/pytouchlinesl.egg-info/top_level.txt +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/setup.cfg +0 -0
- {pytouchlinesl-0.2.0 → pytouchlinesl-0.4.0}/tests/test_zone.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pytouchlinesl
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: An API client for Roth's TouchlineSL control system.
|
|
5
5
|
Author-email: Jon Seager <jon@sgrs.uk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/jnsgruk/pytouchlinesl
|
|
@@ -12,11 +12,12 @@ Requires-Python: >=3.10
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: aiohttp
|
|
15
|
-
Requires-Dist: pydantic
|
|
15
|
+
Requires-Dist: pydantic>=2
|
|
16
16
|
Provides-Extra: dev
|
|
17
17
|
Requires-Dist: pytest; extra == "dev"
|
|
18
18
|
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
19
19
|
Requires-Dist: ruff; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
20
21
|
|
|
21
22
|
# A Python Library for Roth's TouchlineSL System
|
|
22
23
|
|
|
@@ -97,6 +98,8 @@ if __name__ == "__main__":
|
|
|
97
98
|
Contributions in either code or documentation are welcome. The set of features is limited at the
|
|
98
99
|
moment, but I'm happy to expand as the need arises.
|
|
99
100
|
|
|
101
|
+
Commit messages and PR titles should be formatted using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
102
|
+
|
|
100
103
|
The project does not have many dependencies; just `asyncio` and `pytest`/`pytest-asyncio` for
|
|
101
104
|
testing.
|
|
102
105
|
|
|
@@ -137,3 +140,12 @@ ruff check --fix
|
|
|
137
140
|
# Format the code
|
|
138
141
|
ruff format
|
|
139
142
|
```
|
|
143
|
+
|
|
144
|
+
## Releasing
|
|
145
|
+
|
|
146
|
+
Once all the changes have been merged into `main` for a release, use the
|
|
147
|
+
[`.github/tag-release`](./.github/tag-release.sh) script to create a version bump commit in the
|
|
148
|
+
right format, create, **and push** the tag ready for release.
|
|
149
|
+
|
|
150
|
+
This could be automated with Github Actions - but commit signing gets a little complicated, so for
|
|
151
|
+
now it's just a script that can be run by maintainers.
|
|
@@ -77,6 +77,8 @@ if __name__ == "__main__":
|
|
|
77
77
|
Contributions in either code or documentation are welcome. The set of features is limited at the
|
|
78
78
|
moment, but I'm happy to expand as the need arises.
|
|
79
79
|
|
|
80
|
+
Commit messages and PR titles should be formatted using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
81
|
+
|
|
80
82
|
The project does not have many dependencies; just `asyncio` and `pytest`/`pytest-asyncio` for
|
|
81
83
|
testing.
|
|
82
84
|
|
|
@@ -117,3 +119,12 @@ ruff check --fix
|
|
|
117
119
|
# Format the code
|
|
118
120
|
ruff format
|
|
119
121
|
```
|
|
122
|
+
|
|
123
|
+
## Releasing
|
|
124
|
+
|
|
125
|
+
Once all the changes have been merged into `main` for a release, use the
|
|
126
|
+
[`.github/tag-release`](./.github/tag-release.sh) script to create a version bump commit in the
|
|
127
|
+
right format, create, **and push** the tag ready for release.
|
|
128
|
+
|
|
129
|
+
This could be automated with Github Actions - but commit signing gets a little complicated, so for
|
|
130
|
+
now it's just a script that can be run by maintainers.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytouchlinesl"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
authors = [{ name = "Jon Seager", email = "jon@sgrs.uk" }]
|
|
5
5
|
description = "An API client for Roth's TouchlineSL control system."
|
|
6
6
|
readme = "README.md"
|
|
@@ -10,7 +10,7 @@ classifiers = [
|
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Operating System :: OS Independent",
|
|
12
12
|
]
|
|
13
|
-
dependencies = ["aiohttp", "pydantic"]
|
|
13
|
+
dependencies = ["aiohttp", "pydantic>=2"]
|
|
14
14
|
|
|
15
15
|
[project.optional-dependencies]
|
|
16
16
|
dev = ["pytest", "pytest-asyncio", "ruff"]
|
|
@@ -139,21 +139,12 @@ class RothAPI(BaseClient):
|
|
|
139
139
|
or z.zone.id == zone_id
|
|
140
140
|
]
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
i.dict(by_alias=True) for i in schedule.p1_intervals if i.start != 6100
|
|
149
|
-
]
|
|
150
|
-
except AttributeError:
|
|
151
|
-
p0_intervals = [
|
|
152
|
-
i.model_dump(by_alias=True) for i in schedule.p0_intervals if i.start != 6100
|
|
153
|
-
]
|
|
154
|
-
p1_intervals = [
|
|
155
|
-
i.model_dump(by_alias=True) for i in schedule.p1_intervals if i.start != 6100
|
|
156
|
-
]
|
|
142
|
+
p0_intervals = [
|
|
143
|
+
i.model_dump(by_alias=True) for i in schedule.p0_intervals if i.start != 6100
|
|
144
|
+
]
|
|
145
|
+
p1_intervals = [
|
|
146
|
+
i.model_dump(by_alias=True) for i in schedule.p1_intervals if i.start != 6100
|
|
147
|
+
]
|
|
157
148
|
|
|
158
149
|
# TODO: This be simplified with Pydantic models
|
|
159
150
|
data = {
|
|
@@ -6,10 +6,7 @@ tweaks to types and names.
|
|
|
6
6
|
|
|
7
7
|
from typing import Any, Dict, List, Literal, Optional
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
from pydantic.v1 import BaseModel, Field
|
|
11
|
-
except ImportError:
|
|
12
|
-
from pydantic import BaseModel, Field
|
|
9
|
+
from pydantic import BaseModel, Field
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
class ZoneFlagsModel(BaseModel):
|
|
@@ -171,7 +168,7 @@ class AccountModuleModel(BaseModel):
|
|
|
171
168
|
country: Optional[str] = None
|
|
172
169
|
gmt_id: Optional[int] = Field(None, alias="gmtId")
|
|
173
170
|
gmt_time: Optional[str] = Field(None, alias="gmtTime")
|
|
174
|
-
postcode_policy_accepted: bool = Field(None, alias="postcodePolicyAccepted")
|
|
171
|
+
postcode_policy_accepted: Optional[bool] = Field(None, alias="postcodePolicyAccepted")
|
|
175
172
|
style: Optional[str] = None
|
|
176
173
|
version: Optional[str] = None
|
|
177
174
|
company: Optional[str] = None
|
|
@@ -62,7 +62,7 @@ class Module:
|
|
|
62
62
|
self._raw_data: ModuleModel
|
|
63
63
|
# Unix timestamp representing the last time the _raw_data was fetched
|
|
64
64
|
self._last_fetched = 0
|
|
65
|
-
self._cache_validity = cache_validity
|
|
65
|
+
self._cache_validity = cache_validity * 1000
|
|
66
66
|
|
|
67
67
|
self._zones: list[Zone] = []
|
|
68
68
|
self._schedules: list[GlobalScheduleModel] = []
|
|
@@ -96,13 +96,13 @@ class Module:
|
|
|
96
96
|
include_off: (Optional) Include zones which are switched off in the results.
|
|
97
97
|
refresh: (Optional) Force the data to be refreshed using the API.
|
|
98
98
|
"""
|
|
99
|
-
|
|
100
|
-
data = await self._data(refresh=refresh)
|
|
99
|
+
data = await self._data(refresh=refresh)
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
self._zones = []
|
|
102
|
+
for z in data.zones.elements:
|
|
103
|
+
schedule = await self.schedule_by_idx(z.mode.schedule_index)
|
|
104
|
+
zone = Zone(module=self, client=self._client, zone_data=z, schedule=schedule)
|
|
105
|
+
self._zones.append(zone)
|
|
106
106
|
|
|
107
107
|
if include_off:
|
|
108
108
|
return self._zones
|
|
@@ -136,9 +136,8 @@ class Module:
|
|
|
136
136
|
Args:
|
|
137
137
|
refresh: (Optional) Force the data to be refreshed using the API.
|
|
138
138
|
"""
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
self._schedules = data.zones.global_schedules.elements
|
|
139
|
+
data = await self._data(refresh=refresh)
|
|
140
|
+
self._schedules = data.zones.global_schedules.elements
|
|
142
141
|
|
|
143
142
|
return self._schedules
|
|
144
143
|
|
|
@@ -31,13 +31,15 @@ class TouchlineSL:
|
|
|
31
31
|
username: str | None = None,
|
|
32
32
|
password: str | None = None,
|
|
33
33
|
client: BaseClient | None = None,
|
|
34
|
+
cache_validity: int = 30,
|
|
34
35
|
):
|
|
35
36
|
"""Construct the instance with either credentials or an authenticated client.
|
|
36
37
|
|
|
37
38
|
Args:
|
|
38
|
-
username:
|
|
39
|
-
password:
|
|
40
|
-
client:
|
|
39
|
+
username: (Optional) Username for TouchlineSL account. Ignored if client is passed.
|
|
40
|
+
password: (Optional) Password for TouchlineSL account. Ignored if client is passed.
|
|
41
|
+
client: (Optional) An instance of a RothAPI class.
|
|
42
|
+
cache_validity: (Optional) The number of seconds for which module data should be cached.
|
|
41
43
|
"""
|
|
42
44
|
self._modules: list[Module] = []
|
|
43
45
|
|
|
@@ -52,6 +54,8 @@ class TouchlineSL:
|
|
|
52
54
|
raise TypeError("username and password must be strings if no client is provided")
|
|
53
55
|
self._client = RothAPI(username=username, password=password)
|
|
54
56
|
|
|
57
|
+
self._cache_validity = cache_validity
|
|
58
|
+
|
|
55
59
|
async def user_id(self) -> int:
|
|
56
60
|
"""Return the unique user ID of the authenticated account."""
|
|
57
61
|
return await self._client.user_id()
|
|
@@ -64,7 +68,10 @@ class TouchlineSL:
|
|
|
64
68
|
"""
|
|
65
69
|
if not self._modules or refresh:
|
|
66
70
|
data = await self._client.modules()
|
|
67
|
-
self._modules = [
|
|
71
|
+
self._modules = [
|
|
72
|
+
Module(client=self._client, module_data=m, cache_validity=self._cache_validity)
|
|
73
|
+
for m in data
|
|
74
|
+
]
|
|
68
75
|
|
|
69
76
|
return self._modules
|
|
70
77
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pytouchlinesl
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: An API client for Roth's TouchlineSL control system.
|
|
5
5
|
Author-email: Jon Seager <jon@sgrs.uk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/jnsgruk/pytouchlinesl
|
|
@@ -12,11 +12,12 @@ Requires-Python: >=3.10
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: aiohttp
|
|
15
|
-
Requires-Dist: pydantic
|
|
15
|
+
Requires-Dist: pydantic>=2
|
|
16
16
|
Provides-Extra: dev
|
|
17
17
|
Requires-Dist: pytest; extra == "dev"
|
|
18
18
|
Requires-Dist: pytest-asyncio; extra == "dev"
|
|
19
19
|
Requires-Dist: ruff; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
20
21
|
|
|
21
22
|
# A Python Library for Roth's TouchlineSL System
|
|
22
23
|
|
|
@@ -97,6 +98,8 @@ if __name__ == "__main__":
|
|
|
97
98
|
Contributions in either code or documentation are welcome. The set of features is limited at the
|
|
98
99
|
moment, but I'm happy to expand as the need arises.
|
|
99
100
|
|
|
101
|
+
Commit messages and PR titles should be formatted using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
102
|
+
|
|
100
103
|
The project does not have many dependencies; just `asyncio` and `pytest`/`pytest-asyncio` for
|
|
101
104
|
testing.
|
|
102
105
|
|
|
@@ -137,3 +140,12 @@ ruff check --fix
|
|
|
137
140
|
# Format the code
|
|
138
141
|
ruff format
|
|
139
142
|
```
|
|
143
|
+
|
|
144
|
+
## Releasing
|
|
145
|
+
|
|
146
|
+
Once all the changes have been merged into `main` for a release, use the
|
|
147
|
+
[`.github/tag-release`](./.github/tag-release.sh) script to create a version bump commit in the
|
|
148
|
+
right format, create, **and push** the tag ready for release.
|
|
149
|
+
|
|
150
|
+
This could be automated with Github Actions - but commit signing gets a little complicated, so for
|
|
151
|
+
now it's just a script that can be run by maintainers.
|
|
@@ -45,6 +45,16 @@ async def test_zones_cache(test_module):
|
|
|
45
45
|
assert initial_fetch_time == test_module._last_fetched
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
@pytest.mark.asyncio
|
|
49
|
+
async def test_zones_cache_expired(test_module_short_cache):
|
|
50
|
+
await test_module_short_cache.zones()
|
|
51
|
+
initial_fetch_time = test_module_short_cache._last_fetched
|
|
52
|
+
await asyncio.sleep(0.25)
|
|
53
|
+
|
|
54
|
+
await test_module_short_cache.zones()
|
|
55
|
+
assert initial_fetch_time != test_module_short_cache._last_fetched
|
|
56
|
+
|
|
57
|
+
|
|
48
58
|
@pytest.mark.asyncio
|
|
49
59
|
async def test_zones_force_refresh(test_module):
|
|
50
60
|
await test_module.zones()
|
|
@@ -119,6 +129,16 @@ async def test_schedules_cache(test_module):
|
|
|
119
129
|
assert initial_fetch_time == test_module._last_fetched
|
|
120
130
|
|
|
121
131
|
|
|
132
|
+
@pytest.mark.asyncio
|
|
133
|
+
async def test_schedules_cache_expired(test_module_short_cache):
|
|
134
|
+
await test_module_short_cache.schedules()
|
|
135
|
+
initial_fetch_time = test_module_short_cache._last_fetched
|
|
136
|
+
await asyncio.sleep(0.5)
|
|
137
|
+
|
|
138
|
+
await test_module_short_cache.schedules()
|
|
139
|
+
assert initial_fetch_time != test_module_short_cache._last_fetched
|
|
140
|
+
|
|
141
|
+
|
|
122
142
|
@pytest.mark.asyncio
|
|
123
143
|
async def test_schedules_force_refresh(test_module):
|
|
124
144
|
await test_module.schedules()
|
|
@@ -40,6 +40,15 @@ async def test_modules(test_touchlinesl: TouchlineSL):
|
|
|
40
40
|
modules = await test_touchlinesl.modules()
|
|
41
41
|
for m in modules:
|
|
42
42
|
assert isinstance(m, Module)
|
|
43
|
+
assert m._cache_validity == 30000
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_modules_short_cache(test_touchlinesl_short_cache: TouchlineSL):
|
|
48
|
+
modules = await test_touchlinesl_short_cache.modules()
|
|
49
|
+
for m in modules:
|
|
50
|
+
assert isinstance(m, Module)
|
|
51
|
+
assert m._cache_validity == 100
|
|
43
52
|
|
|
44
53
|
|
|
45
54
|
@pytest.mark.asyncio
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|