weishaupt-webif-api 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.
- weishaupt_webif_api-0.1.0/LICENSE +21 -0
- weishaupt_webif_api-0.1.0/PKG-INFO +111 -0
- weishaupt_webif_api-0.1.0/README.md +82 -0
- weishaupt_webif_api-0.1.0/pyproject.toml +94 -0
- weishaupt_webif_api-0.1.0/setup.cfg +4 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api/__init__.py +24 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api/__main__.py +158 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api/api.py +545 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api/const.py +50 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api/exceptions.py +17 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/PKG-INFO +111 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/SOURCES.txt +16 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/dependency_links.txt +1 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/entry_points.txt +2 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/requires.txt +7 -0
- weishaupt_webif_api-0.1.0/src/weishaupt_webif_api.egg-info/top_level.txt +1 -0
- weishaupt_webif_api-0.1.0/tests/test_api.py +106 -0
- weishaupt_webif_api-0.1.0/tests/test_parser.py +26 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
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,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weishaupt-webif-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async Python library for the Weishaupt WebIF heat pump interface.
|
|
5
|
+
Author-email: Mad_One <madone85@googlemail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/MadOne/weishaupt_webif_api
|
|
8
|
+
Project-URL: Repository, https://github.com/MadOne/weishaupt_webif_api
|
|
9
|
+
Project-URL: Issues, https://github.com/MadOne/weishaupt_webif_api/issues
|
|
10
|
+
Keywords: weishaupt,heatpump,heat-pump,home-assistant,hvac,webif
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Home Automation
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: httpx>=0.24
|
|
23
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
|
|
27
|
+
Requires-Dist: respx>=0.20.0; extra == "test"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Weishaupt WebIF API
|
|
31
|
+
|
|
32
|
+
A Python library for interacting asynchronously with the Weishaupt heating system web interface (WebIF). This library allows you to programmatically retrieve telemetry data and system statistics.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Asynchronous Design**: Built on `httpx` and `asyncio` for non-blocking I/O.
|
|
37
|
+
- **Selective Updates**: Fetch only the categories you need (e.g., "Statistik", "Heizkreis") to minimize load on the device's MCU.
|
|
38
|
+
- **Persistence**: Automatically manages session cookies and internal state (cooldowns, request timing) across restarts using local storage.
|
|
39
|
+
- **Smart Batching**: Includes logic to batch requests safely, preventing resource exhaustion on the hardware interface.
|
|
40
|
+
- **Robust Error Handling**: Detects session expiration, login redirections, and MCU resource errors.
|
|
41
|
+
- **Mock Mode**: Access real-world sample data without polling the device—perfect for developing Home Assistant integrations.
|
|
42
|
+
- **CLI Monitor**: A built-in command-line tool to monitor your heat pump telemetry in real-time.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Currently, this library can be installed locally:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install .
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import asyncio
|
|
56
|
+
from weishaupt_webif_api import WebifConnection
|
|
57
|
+
|
|
58
|
+
async def main():
|
|
59
|
+
# Initialize the connection
|
|
60
|
+
async with WebifConnection(
|
|
61
|
+
ip="10.10.1.225",
|
|
62
|
+
username="user",
|
|
63
|
+
password="pass",
|
|
64
|
+
storage_path="./data"
|
|
65
|
+
) as api:
|
|
66
|
+
# Fetch specific categories
|
|
67
|
+
data = await api.update_all(["Statistik", "Heizkreis"])
|
|
68
|
+
|
|
69
|
+
# Fetch mockup data for developement puposes. This is no real data and wont change!
|
|
70
|
+
mcok_data = await api.update_all_mock(["Statistik", "Heizkreis"])
|
|
71
|
+
|
|
72
|
+
for category, values in data.items():
|
|
73
|
+
print(f"--- {category} ---")
|
|
74
|
+
for key, value in values.items():
|
|
75
|
+
print(f"{key}: {value}")
|
|
76
|
+
|
|
77
|
+
if __name__ == "__main__":
|
|
78
|
+
asyncio.run(main())
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Configuration & State
|
|
84
|
+
|
|
85
|
+
The library creates several files in the `storage_path` to maintain state:
|
|
86
|
+
|
|
87
|
+
- `lwp_cookies.txt`: Stores session cookies to avoid redundant logins.
|
|
88
|
+
- `lwp_state.json`: Stores internal metadata, such as request cooldown timers.
|
|
89
|
+
- `weishaupt_webif_api.log`: Contains diagnostic logs for troubleshooting.
|
|
90
|
+
|
|
91
|
+
These files are excluded from version control by default via `.gitignore`.
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
### Running Tests
|
|
96
|
+
|
|
97
|
+
The project uses `pytest` with `pytest-asyncio` and `respx` for mocking API responses.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pytest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Tests utilize HTML fixtures located in `tests/fixtures/` to simulate real device responses without requiring access to physical hardware.
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
108
|
+
|
|
109
|
+
## Disclaimer
|
|
110
|
+
|
|
111
|
+
*This project is not affiliated with or endorsed by Weishaupt. Use it at your own risk. Frequent polling can put significant stress on the device's web interface.*
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Weishaupt WebIF API
|
|
2
|
+
|
|
3
|
+
A Python library for interacting asynchronously with the Weishaupt heating system web interface (WebIF). This library allows you to programmatically retrieve telemetry data and system statistics.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Asynchronous Design**: Built on `httpx` and `asyncio` for non-blocking I/O.
|
|
8
|
+
- **Selective Updates**: Fetch only the categories you need (e.g., "Statistik", "Heizkreis") to minimize load on the device's MCU.
|
|
9
|
+
- **Persistence**: Automatically manages session cookies and internal state (cooldowns, request timing) across restarts using local storage.
|
|
10
|
+
- **Smart Batching**: Includes logic to batch requests safely, preventing resource exhaustion on the hardware interface.
|
|
11
|
+
- **Robust Error Handling**: Detects session expiration, login redirections, and MCU resource errors.
|
|
12
|
+
- **Mock Mode**: Access real-world sample data without polling the device—perfect for developing Home Assistant integrations.
|
|
13
|
+
- **CLI Monitor**: A built-in command-line tool to monitor your heat pump telemetry in real-time.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Currently, this library can be installed locally:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install .
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import asyncio
|
|
27
|
+
from weishaupt_webif_api import WebifConnection
|
|
28
|
+
|
|
29
|
+
async def main():
|
|
30
|
+
# Initialize the connection
|
|
31
|
+
async with WebifConnection(
|
|
32
|
+
ip="10.10.1.225",
|
|
33
|
+
username="user",
|
|
34
|
+
password="pass",
|
|
35
|
+
storage_path="./data"
|
|
36
|
+
) as api:
|
|
37
|
+
# Fetch specific categories
|
|
38
|
+
data = await api.update_all(["Statistik", "Heizkreis"])
|
|
39
|
+
|
|
40
|
+
# Fetch mockup data for developement puposes. This is no real data and wont change!
|
|
41
|
+
mcok_data = await api.update_all_mock(["Statistik", "Heizkreis"])
|
|
42
|
+
|
|
43
|
+
for category, values in data.items():
|
|
44
|
+
print(f"--- {category} ---")
|
|
45
|
+
for key, value in values.items():
|
|
46
|
+
print(f"{key}: {value}")
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
asyncio.run(main())
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Configuration & State
|
|
55
|
+
|
|
56
|
+
The library creates several files in the `storage_path` to maintain state:
|
|
57
|
+
|
|
58
|
+
- `lwp_cookies.txt`: Stores session cookies to avoid redundant logins.
|
|
59
|
+
- `lwp_state.json`: Stores internal metadata, such as request cooldown timers.
|
|
60
|
+
- `weishaupt_webif_api.log`: Contains diagnostic logs for troubleshooting.
|
|
61
|
+
|
|
62
|
+
These files are excluded from version control by default via `.gitignore`.
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
### Running Tests
|
|
67
|
+
|
|
68
|
+
The project uses `pytest` with `pytest-asyncio` and `respx` for mocking API responses.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pytest
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Tests utilize HTML fixtures located in `tests/fixtures/` to simulate real device responses without requiring access to physical hardware.
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
79
|
+
|
|
80
|
+
## Disclaimer
|
|
81
|
+
|
|
82
|
+
*This project is not affiliated with or endorsed by Weishaupt. Use it at your own risk. Frequent polling can put significant stress on the device's web interface.*
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "weishaupt-webif-api"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Async Python library for the Weishaupt WebIF heat pump interface."
|
|
9
|
+
readme = {file = "README.md", content-type = "text/markdown"}
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Mad_One", email = "madone85@googlemail.com"},
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"httpx>=0.24",
|
|
17
|
+
"beautifulsoup4>=4.12",
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Development Status :: 3 - Alpha",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Programming Language :: Python :: 3.13",
|
|
27
|
+
"Topic :: Home Automation",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
keywords = [
|
|
31
|
+
"weishaupt",
|
|
32
|
+
"heatpump",
|
|
33
|
+
"heat-pump",
|
|
34
|
+
"home-assistant",
|
|
35
|
+
"hvac",
|
|
36
|
+
"webif",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
test = [
|
|
41
|
+
"pytest>=7.0",
|
|
42
|
+
"pytest-asyncio>=0.21.0",
|
|
43
|
+
"respx>=0.20.0",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
weishaupt-api = "weishaupt_webif_api.__main__:main"
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/MadOne/weishaupt_webif_api"
|
|
51
|
+
Repository = "https://github.com/MadOne/weishaupt_webif_api"
|
|
52
|
+
Issues = "https://github.com/MadOne/weishaupt_webif_api/issues"
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
asyncio_mode = "auto"
|
|
56
|
+
testpaths = ["tests"]
|
|
57
|
+
python_files = "test_*.py"
|
|
58
|
+
filterwarnings = [
|
|
59
|
+
"ignore::DeprecationWarning",
|
|
60
|
+
]
|
|
61
|
+
[tool.setuptools]
|
|
62
|
+
package-dir = {"" = "src"}
|
|
63
|
+
|
|
64
|
+
[tool.ruff]
|
|
65
|
+
line-length = 88
|
|
66
|
+
target-version = "py311"
|
|
67
|
+
src = ["weishaupt_webif_api", "tests"]
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint]
|
|
70
|
+
select = [
|
|
71
|
+
"ALL"
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
ignore = [
|
|
75
|
+
"D203", # one-blank-line-before-class (incompatible with D211)
|
|
76
|
+
"D213", # multi-line-summary-second-line (incompatible with D212)
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint.per-file-ignores]
|
|
80
|
+
# Ignore S101 (assert statements) in all test files
|
|
81
|
+
"tests/**/*.py" = ["S101"]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
[tool.ruff.format]
|
|
87
|
+
quote-style = "double"
|
|
88
|
+
indent-style = "space"
|
|
89
|
+
line-ending = "lf"
|
|
90
|
+
|
|
91
|
+
[tool.mypy]
|
|
92
|
+
python_version = "3.11"
|
|
93
|
+
warn_return_any = true
|
|
94
|
+
warn_unused_configs = true
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Asynchronous API for Weishaupt WebIF (Heat Pumps)."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
from .api import WebifConnection
|
|
6
|
+
from .const import EXPECTED_COUNTS, ColoredFormatter, Info
|
|
7
|
+
from .exceptions import (
|
|
8
|
+
ConnectionTimeoutError,
|
|
9
|
+
McuResourceError,
|
|
10
|
+
SessionExpiredError,
|
|
11
|
+
WeishauptWebifError,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"EXPECTED_COUNTS",
|
|
16
|
+
"ColoredFormatter",
|
|
17
|
+
"ConnectionTimeoutError",
|
|
18
|
+
"Info",
|
|
19
|
+
"McuResourceError",
|
|
20
|
+
"SessionExpiredError",
|
|
21
|
+
"WebifConnection",
|
|
22
|
+
"WeishauptWebifError",
|
|
23
|
+
"__version__",
|
|
24
|
+
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Command line interface for the Weishaupt WebIF API."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import asyncio
|
|
5
|
+
import contextlib
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from .api import WebifConnection
|
|
11
|
+
from .const import ColoredFormatter
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def _main(args: argparse.Namespace) -> None:
|
|
15
|
+
storage_path = Path(args.path) if args.path else Path.cwd()
|
|
16
|
+
|
|
17
|
+
# Configure logging for the console
|
|
18
|
+
logger = logging.getLogger("weishaupt_webif_api")
|
|
19
|
+
log_level = logging.DEBUG if args.debug else logging.INFO
|
|
20
|
+
logger.setLevel(log_level)
|
|
21
|
+
|
|
22
|
+
# Console Handler (Colored)
|
|
23
|
+
sh = logging.StreamHandler()
|
|
24
|
+
sh.setFormatter(ColoredFormatter())
|
|
25
|
+
logger.addHandler(sh)
|
|
26
|
+
|
|
27
|
+
# File Handler (Persistent log)
|
|
28
|
+
log_file = storage_path / "weishaupt_webif_api.log"
|
|
29
|
+
fh = logging.FileHandler(str(log_file))
|
|
30
|
+
fh.setFormatter(
|
|
31
|
+
logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s"),
|
|
32
|
+
)
|
|
33
|
+
logger.addHandler(fh)
|
|
34
|
+
|
|
35
|
+
logger.info("Starting Weishaupt WebIF API monitor for %s...", args.ip)
|
|
36
|
+
async with WebifConnection(
|
|
37
|
+
args.ip,
|
|
38
|
+
args.user,
|
|
39
|
+
args.password,
|
|
40
|
+
request_delay=args.request_delay,
|
|
41
|
+
cooldown_delay=args.cooldown_delay,
|
|
42
|
+
storage_path=storage_path,
|
|
43
|
+
) as con:
|
|
44
|
+
try:
|
|
45
|
+
while True:
|
|
46
|
+
try:
|
|
47
|
+
# Fetch all data
|
|
48
|
+
if args.mock:
|
|
49
|
+
data = await con.update_all_mock()
|
|
50
|
+
else:
|
|
51
|
+
data = await con.update_all()
|
|
52
|
+
summary = ", ".join(
|
|
53
|
+
[f"[{cat}]: {len(vals)}" for cat, vals in data.items()],
|
|
54
|
+
)
|
|
55
|
+
logger.info(
|
|
56
|
+
"Update Success: %s. Next check in %ds.",
|
|
57
|
+
summary,
|
|
58
|
+
args.interval,
|
|
59
|
+
)
|
|
60
|
+
await asyncio.sleep(args.interval)
|
|
61
|
+
except (asyncio.CancelledError, KeyboardInterrupt):
|
|
62
|
+
raise
|
|
63
|
+
except Exception as err: # noqa: BLE001
|
|
64
|
+
logger.error( # noqa: TRY400
|
|
65
|
+
"Update failed: %s. Retrying in %ds...",
|
|
66
|
+
err,
|
|
67
|
+
args.retry_interval,
|
|
68
|
+
)
|
|
69
|
+
await asyncio.sleep(args.retry_interval)
|
|
70
|
+
except (asyncio.CancelledError, KeyboardInterrupt):
|
|
71
|
+
# Graceful exit on Ctrl+C
|
|
72
|
+
pass
|
|
73
|
+
except Exception as err: # noqa: BLE001
|
|
74
|
+
logger.critical("Monitor encountered an error: %s", err)
|
|
75
|
+
finally:
|
|
76
|
+
logger.info("--- Final Communication Statistics ---")
|
|
77
|
+
for key, value in con.stats.items():
|
|
78
|
+
logger.info("%-20s: %s", key, value)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def main() -> None:
|
|
82
|
+
"""Sync wrapper for the entry point."""
|
|
83
|
+
parser = argparse.ArgumentParser(
|
|
84
|
+
description="Weishaupt WebIF API CLI",
|
|
85
|
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
86
|
+
)
|
|
87
|
+
parser.add_argument(
|
|
88
|
+
"ip",
|
|
89
|
+
nargs="?" if os.environ.get("WEISHAUPT_IP") else None,
|
|
90
|
+
default=os.environ.get("WEISHAUPT_IP"),
|
|
91
|
+
help="IP address of the Weishaupt module (env: WEISHAUPT_IP)",
|
|
92
|
+
)
|
|
93
|
+
parser.add_argument(
|
|
94
|
+
"user",
|
|
95
|
+
nargs="?" if os.environ.get("WEISHAUPT_USER") else None,
|
|
96
|
+
default=os.environ.get("WEISHAUPT_USER"),
|
|
97
|
+
help="Login username (env: WEISHAUPT_USER)",
|
|
98
|
+
)
|
|
99
|
+
parser.add_argument(
|
|
100
|
+
"password",
|
|
101
|
+
nargs="?" if os.environ.get("WEISHAUPT_PASSWORD") else None,
|
|
102
|
+
default=os.environ.get("WEISHAUPT_PASSWORD"),
|
|
103
|
+
help="Login password (env: WEISHAUPT_PASSWORD)",
|
|
104
|
+
)
|
|
105
|
+
parser.add_argument(
|
|
106
|
+
"--path",
|
|
107
|
+
help="Directory to store logs and state files (defaults to execution folder)",
|
|
108
|
+
default=None,
|
|
109
|
+
)
|
|
110
|
+
parser.add_argument(
|
|
111
|
+
"--interval",
|
|
112
|
+
type=int,
|
|
113
|
+
help="Polling interval in seconds (default: 300)",
|
|
114
|
+
default=300,
|
|
115
|
+
)
|
|
116
|
+
parser.add_argument(
|
|
117
|
+
"--retry-interval",
|
|
118
|
+
type=int,
|
|
119
|
+
help="Retry interval after failure in seconds",
|
|
120
|
+
default=60,
|
|
121
|
+
)
|
|
122
|
+
parser.add_argument(
|
|
123
|
+
"--request-delay",
|
|
124
|
+
type=float,
|
|
125
|
+
help="Internal breather delay between requests in seconds",
|
|
126
|
+
default=60.0,
|
|
127
|
+
)
|
|
128
|
+
parser.add_argument(
|
|
129
|
+
"--cooldown-delay",
|
|
130
|
+
type=float,
|
|
131
|
+
help="Internal cooldown penalty after failure in seconds",
|
|
132
|
+
default=300.0,
|
|
133
|
+
)
|
|
134
|
+
parser.add_argument(
|
|
135
|
+
"--debug",
|
|
136
|
+
action="store_true",
|
|
137
|
+
help="Enable debug logging",
|
|
138
|
+
)
|
|
139
|
+
parser.add_argument(
|
|
140
|
+
"--mock",
|
|
141
|
+
action="store_true",
|
|
142
|
+
help="Use mock data for development without polling the device",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
args = parser.parse_args()
|
|
146
|
+
|
|
147
|
+
if not all([args.ip, args.user, args.password]):
|
|
148
|
+
parser.error(
|
|
149
|
+
"IP, user, and password must be provided via arguments or "
|
|
150
|
+
"environment variables.",
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
with contextlib.suppress(KeyboardInterrupt):
|
|
154
|
+
asyncio.run(_main(args))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
main()
|