python-rako-2025 0.0.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.
- python_rako_2025-0.0.1/LICENSE +21 -0
- python_rako_2025-0.0.1/PKG-INFO +174 -0
- python_rako_2025-0.0.1/README.md +138 -0
- python_rako_2025-0.0.1/pyproject.toml +86 -0
- python_rako_2025-0.0.1/python_rako/__init__.py +60 -0
- python_rako_2025-0.0.1/python_rako/__version__.py +2 -0
- python_rako_2025-0.0.1/python_rako/bridge.py +283 -0
- python_rako_2025-0.0.1/python_rako/const.py +59 -0
- python_rako_2025-0.0.1/python_rako/exceptions.py +2 -0
- python_rako_2025-0.0.1/python_rako/helpers.py +204 -0
- python_rako_2025-0.0.1/python_rako/model.py +148 -0
- python_rako_2025-0.0.1/python_rako/py.typed +0 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/PKG-INFO +174 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/SOURCES.txt +21 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/dependency_links.txt +1 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/not-zip-safe +1 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/requires.txt +3 -0
- python_rako_2025-0.0.1/python_rako_2025.egg-info/top_level.txt +1 -0
- python_rako_2025-0.0.1/setup.cfg +4 -0
- python_rako_2025-0.0.1/setup.py +52 -0
- python_rako_2025-0.0.1/tests/test_bridge.py +99 -0
- python_rako_2025-0.0.1/tests/test_helpers.py +178 -0
- python_rako_2025-0.0.1/tests/test_model.py +74 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Ben Marengo
|
|
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,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-rako-2025
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Asynchronous Python client for Rako Controls Lighting
|
|
5
|
+
Home-page: https://github.com/simonleigh/python-rako
|
|
6
|
+
Author: Simon Leigh
|
|
7
|
+
Author-email: Simon Leigh <simonleigh@users.noreply.github.com>
|
|
8
|
+
Project-URL: Homepage, https://github.com/simonleigh/python-rako
|
|
9
|
+
Project-URL: Repository, https://github.com/simonleigh/python-rako
|
|
10
|
+
Project-URL: Issues, https://github.com/simonleigh/python-rako/issues
|
|
11
|
+
Keywords: rako,controls,api,async,client
|
|
12
|
+
Platform: any
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: aiohttp>=3.10.0
|
|
29
|
+
Requires-Dist: asyncio-dgram>=2.2.0
|
|
30
|
+
Requires-Dist: xmltodict>=0.13.0
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: home-page
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: platform
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
|
|
37
|
+
# Python: Rako Controls API Client
|
|
38
|
+
|
|
39
|
+
[![GitHub Release][releases-shield]][releases]
|
|
40
|
+
![Project Stage][project-stage-shield]
|
|
41
|
+
![Project Maintenance][maintenance-shield]
|
|
42
|
+
[![License][license-shield]](LICENSE)
|
|
43
|
+
|
|
44
|
+
[![Build Status][build-shield]][build]
|
|
45
|
+
[![Code Coverage][codecov-shield]][codecov]
|
|
46
|
+
[![Code Quality][code-quality-shield]][code-quality]
|
|
47
|
+
|
|
48
|
+
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
|
|
49
|
+
|
|
50
|
+
Asynchronous Python client for Rako Controls.
|
|
51
|
+
|
|
52
|
+
## About
|
|
53
|
+
|
|
54
|
+
This package allows you to control and monitor Rako Controls devices
|
|
55
|
+
programmatically. It is mainly created to allow third-party programs to automate
|
|
56
|
+
their behavior.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install python-rako
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import asyncio
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
async def main():
|
|
71
|
+
# TODO
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
loop = asyncio.get_event_loop()
|
|
77
|
+
loop.run_until_complete(main())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Changelog & Releases
|
|
81
|
+
|
|
82
|
+
This repository keeps a change log using [GitHub's releases][releases]
|
|
83
|
+
functionality. The format of the log is based on
|
|
84
|
+
[Keep a Changelog][keepchangelog].
|
|
85
|
+
|
|
86
|
+
Releases are based on [Semantic Versioning][semver], and use the format
|
|
87
|
+
of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented
|
|
88
|
+
based on the following:
|
|
89
|
+
|
|
90
|
+
- ``MAJOR``: Incompatible or major changes.
|
|
91
|
+
- ``MINOR``: Backwards-compatible new features and enhancements.
|
|
92
|
+
- ``PATCH``: Backwards-compatible bugfixes and package updates.
|
|
93
|
+
|
|
94
|
+
## Contributing
|
|
95
|
+
|
|
96
|
+
This is an active open-source project. We are always open to people who want to
|
|
97
|
+
use the code or contribute to it.
|
|
98
|
+
|
|
99
|
+
We've set up a separate document for our
|
|
100
|
+
[contribution guidelines](CONTRIBUTING.md).
|
|
101
|
+
|
|
102
|
+
Thank you for being involved! :heart_eyes:
|
|
103
|
+
|
|
104
|
+
## Setting up development environment
|
|
105
|
+
|
|
106
|
+
In case you'd like to contribute, a `Makefile` has been included to ensure a
|
|
107
|
+
quick start.
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
make venv
|
|
111
|
+
source ./venv/bin/activate
|
|
112
|
+
make dev
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Now you can start developing, run `make` without arguments to get an overview
|
|
116
|
+
of all make goals that are available (including description):
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ make
|
|
120
|
+
Asynchronous Python client for Rako Controls Lighting.
|
|
121
|
+
|
|
122
|
+
Usage:
|
|
123
|
+
make help Shows this message.
|
|
124
|
+
make dev Set up a development environment.
|
|
125
|
+
make lint Run all linters.
|
|
126
|
+
make lint-black Run linting using black & blacken-docs.
|
|
127
|
+
make lint-flake8 Run linting using flake8 (pycodestyle/pydocstyle).
|
|
128
|
+
make lint-pylint Run linting using PyLint.
|
|
129
|
+
make lint-mypy Run linting using MyPy.
|
|
130
|
+
make test Run tests quickly with the default Python.
|
|
131
|
+
make coverage Check code coverage quickly with the default Python.
|
|
132
|
+
make install Install the package to the active Python's site-packages.
|
|
133
|
+
make clean Removes build, test, coverage and Python artifacts.
|
|
134
|
+
make clean-all Removes all venv, build, test, coverage and Python artifacts.
|
|
135
|
+
make clean-build Removes build artifacts.
|
|
136
|
+
make clean-pyc Removes Python file artifacts.
|
|
137
|
+
make clean-test Removes test and coverage artifacts.
|
|
138
|
+
make clean-venv Removes Python virtual environment artifacts.
|
|
139
|
+
make dist Builds source and wheel package.
|
|
140
|
+
make release Release build on PyP
|
|
141
|
+
make venv Create Python venv environment.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Authors & contributors
|
|
145
|
+
|
|
146
|
+
The original setup of this repository is by [Ben Marengo][marengaz].
|
|
147
|
+
|
|
148
|
+
For a full list of all authors and contributors,
|
|
149
|
+
check [the contributor's page][contributors].
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
[License](LICENSE)
|
|
154
|
+
|
|
155
|
+
[build-shield]: https://github.com/marengaz/python-rako/workflows/Continuous%20Integration/badge.svg
|
|
156
|
+
[build]: https://github.com/marengaz/python-rako/actions
|
|
157
|
+
[code-quality-shield]: https://img.shields.io/lgtm/grade/python/g/marengaz/python-rako.svg?logo=lgtm&logoWidth=18
|
|
158
|
+
[code-quality]: https://lgtm.com/projects/g/marengaz/python-rako/context:python
|
|
159
|
+
[codecov-shield]: https://codecov.io/gh/marengaz/python-rako/branch/master/graph/badge.svg
|
|
160
|
+
[codecov]: https://codecov.io/gh/marengaz/python-rako
|
|
161
|
+
[contributors]: https://github.com/marengaz/python-rako/graphs/contributors
|
|
162
|
+
[marengaz]: https://github.com/marengaz
|
|
163
|
+
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
|
|
164
|
+
[license-shield]: https://img.shields.io/github/license/marengaz/python-rako.svg
|
|
165
|
+
[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg
|
|
166
|
+
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
|
167
|
+
[releases-shield]: https://img.shields.io/github/release/marengaz/python-rako.svg
|
|
168
|
+
[releases]: https://github.com/marengaz/python-rako/releases
|
|
169
|
+
[semver]: http://semver.org/spec/v2.0.0.html
|
|
170
|
+
|
|
171
|
+
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
|
|
172
|
+
[buymeacoffee]: https://www.buymeacoffee.com/marengaz
|
|
173
|
+
[github-actions-shield]: https://github.com/marengaz/rakomqtt/workflows/Test%20RakoMQTT/badge.svg?branch=master
|
|
174
|
+
[github-actions]: https://github.com/marengaz/rakomqtt/actions?query=workflow%3A%22Test+RakoMQTT%22+branch%3Amaster
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Python: Rako Controls API Client
|
|
2
|
+
|
|
3
|
+
[![GitHub Release][releases-shield]][releases]
|
|
4
|
+
![Project Stage][project-stage-shield]
|
|
5
|
+
![Project Maintenance][maintenance-shield]
|
|
6
|
+
[![License][license-shield]](LICENSE)
|
|
7
|
+
|
|
8
|
+
[![Build Status][build-shield]][build]
|
|
9
|
+
[![Code Coverage][codecov-shield]][codecov]
|
|
10
|
+
[![Code Quality][code-quality-shield]][code-quality]
|
|
11
|
+
|
|
12
|
+
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
|
|
13
|
+
|
|
14
|
+
Asynchronous Python client for Rako Controls.
|
|
15
|
+
|
|
16
|
+
## About
|
|
17
|
+
|
|
18
|
+
This package allows you to control and monitor Rako Controls devices
|
|
19
|
+
programmatically. It is mainly created to allow third-party programs to automate
|
|
20
|
+
their behavior.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install python-rako
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import asyncio
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async def main():
|
|
35
|
+
# TODO
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if __name__ == "__main__":
|
|
40
|
+
loop = asyncio.get_event_loop()
|
|
41
|
+
loop.run_until_complete(main())
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Changelog & Releases
|
|
45
|
+
|
|
46
|
+
This repository keeps a change log using [GitHub's releases][releases]
|
|
47
|
+
functionality. The format of the log is based on
|
|
48
|
+
[Keep a Changelog][keepchangelog].
|
|
49
|
+
|
|
50
|
+
Releases are based on [Semantic Versioning][semver], and use the format
|
|
51
|
+
of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented
|
|
52
|
+
based on the following:
|
|
53
|
+
|
|
54
|
+
- ``MAJOR``: Incompatible or major changes.
|
|
55
|
+
- ``MINOR``: Backwards-compatible new features and enhancements.
|
|
56
|
+
- ``PATCH``: Backwards-compatible bugfixes and package updates.
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
This is an active open-source project. We are always open to people who want to
|
|
61
|
+
use the code or contribute to it.
|
|
62
|
+
|
|
63
|
+
We've set up a separate document for our
|
|
64
|
+
[contribution guidelines](CONTRIBUTING.md).
|
|
65
|
+
|
|
66
|
+
Thank you for being involved! :heart_eyes:
|
|
67
|
+
|
|
68
|
+
## Setting up development environment
|
|
69
|
+
|
|
70
|
+
In case you'd like to contribute, a `Makefile` has been included to ensure a
|
|
71
|
+
quick start.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
make venv
|
|
75
|
+
source ./venv/bin/activate
|
|
76
|
+
make dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Now you can start developing, run `make` without arguments to get an overview
|
|
80
|
+
of all make goals that are available (including description):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
$ make
|
|
84
|
+
Asynchronous Python client for Rako Controls Lighting.
|
|
85
|
+
|
|
86
|
+
Usage:
|
|
87
|
+
make help Shows this message.
|
|
88
|
+
make dev Set up a development environment.
|
|
89
|
+
make lint Run all linters.
|
|
90
|
+
make lint-black Run linting using black & blacken-docs.
|
|
91
|
+
make lint-flake8 Run linting using flake8 (pycodestyle/pydocstyle).
|
|
92
|
+
make lint-pylint Run linting using PyLint.
|
|
93
|
+
make lint-mypy Run linting using MyPy.
|
|
94
|
+
make test Run tests quickly with the default Python.
|
|
95
|
+
make coverage Check code coverage quickly with the default Python.
|
|
96
|
+
make install Install the package to the active Python's site-packages.
|
|
97
|
+
make clean Removes build, test, coverage and Python artifacts.
|
|
98
|
+
make clean-all Removes all venv, build, test, coverage and Python artifacts.
|
|
99
|
+
make clean-build Removes build artifacts.
|
|
100
|
+
make clean-pyc Removes Python file artifacts.
|
|
101
|
+
make clean-test Removes test and coverage artifacts.
|
|
102
|
+
make clean-venv Removes Python virtual environment artifacts.
|
|
103
|
+
make dist Builds source and wheel package.
|
|
104
|
+
make release Release build on PyP
|
|
105
|
+
make venv Create Python venv environment.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Authors & contributors
|
|
109
|
+
|
|
110
|
+
The original setup of this repository is by [Ben Marengo][marengaz].
|
|
111
|
+
|
|
112
|
+
For a full list of all authors and contributors,
|
|
113
|
+
check [the contributor's page][contributors].
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
[License](LICENSE)
|
|
118
|
+
|
|
119
|
+
[build-shield]: https://github.com/marengaz/python-rako/workflows/Continuous%20Integration/badge.svg
|
|
120
|
+
[build]: https://github.com/marengaz/python-rako/actions
|
|
121
|
+
[code-quality-shield]: https://img.shields.io/lgtm/grade/python/g/marengaz/python-rako.svg?logo=lgtm&logoWidth=18
|
|
122
|
+
[code-quality]: https://lgtm.com/projects/g/marengaz/python-rako/context:python
|
|
123
|
+
[codecov-shield]: https://codecov.io/gh/marengaz/python-rako/branch/master/graph/badge.svg
|
|
124
|
+
[codecov]: https://codecov.io/gh/marengaz/python-rako
|
|
125
|
+
[contributors]: https://github.com/marengaz/python-rako/graphs/contributors
|
|
126
|
+
[marengaz]: https://github.com/marengaz
|
|
127
|
+
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
|
|
128
|
+
[license-shield]: https://img.shields.io/github/license/marengaz/python-rako.svg
|
|
129
|
+
[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg
|
|
130
|
+
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
|
131
|
+
[releases-shield]: https://img.shields.io/github/release/marengaz/python-rako.svg
|
|
132
|
+
[releases]: https://github.com/marengaz/python-rako/releases
|
|
133
|
+
[semver]: http://semver.org/spec/v2.0.0.html
|
|
134
|
+
|
|
135
|
+
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
|
|
136
|
+
[buymeacoffee]: https://www.buymeacoffee.com/marengaz
|
|
137
|
+
[github-actions-shield]: https://github.com/marengaz/rakomqtt/workflows/Test%20RakoMQTT/badge.svg?branch=master
|
|
138
|
+
[github-actions]: https://github.com/marengaz/rakomqtt/actions?query=workflow%3A%22Test+RakoMQTT%22+branch%3Amaster
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-rako-2025"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Asynchronous Python client for Rako Controls Lighting"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
keywords = ["rako", "controls", "api", "async", "client"]
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Simon Leigh", email = "simonleigh@users.noreply.github.com"},
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Natural Language :: English",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
27
|
+
]
|
|
28
|
+
requires-python = ">=3.10"
|
|
29
|
+
dependencies = [
|
|
30
|
+
"aiohttp>=3.10.0",
|
|
31
|
+
"asyncio-dgram>=2.2.0",
|
|
32
|
+
"xmltodict>=0.13.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/simonleigh/python-rako"
|
|
37
|
+
Repository = "https://github.com/simonleigh/python-rako"
|
|
38
|
+
Issues = "https://github.com/simonleigh/python-rako/issues"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
include = ["python_rako*"]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.package-data]
|
|
45
|
+
python_rako = ["py.typed"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
target-version = "py310"
|
|
49
|
+
line-length = 100
|
|
50
|
+
select = [
|
|
51
|
+
"E", # pycodestyle errors
|
|
52
|
+
"W", # pycodestyle warnings
|
|
53
|
+
"F", # pyflakes
|
|
54
|
+
"I", # isort
|
|
55
|
+
"B", # flake8-bugbear
|
|
56
|
+
"C4", # flake8-comprehensions
|
|
57
|
+
"UP", # pyupgrade
|
|
58
|
+
"PL", # pylint
|
|
59
|
+
]
|
|
60
|
+
ignore = [
|
|
61
|
+
"E501", # line too long, handled by black
|
|
62
|
+
"B008", # do not perform function calls in argument defaults
|
|
63
|
+
"C901", # too complex
|
|
64
|
+
"PLR0913", # too many arguments
|
|
65
|
+
"PLR0912", # too many branches
|
|
66
|
+
"PLR0915", # too many statements
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.ruff.per-file-ignores]
|
|
70
|
+
"tests/*" = ["PLR2004"]
|
|
71
|
+
|
|
72
|
+
[tool.mypy]
|
|
73
|
+
python_version = "3.10"
|
|
74
|
+
check_untyped_defs = true
|
|
75
|
+
disallow_any_generics = true
|
|
76
|
+
disallow_incomplete_defs = true
|
|
77
|
+
disallow_untyped_defs = true
|
|
78
|
+
no_implicit_optional = true
|
|
79
|
+
warn_redundant_casts = true
|
|
80
|
+
warn_unused_ignores = true
|
|
81
|
+
warn_return_any = true
|
|
82
|
+
warn_unreachable = true
|
|
83
|
+
strict_equality = true
|
|
84
|
+
|
|
85
|
+
[tool.pytest.ini_options]
|
|
86
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
import socket
|
|
6
|
+
from asyncio.trsock import TransportSocket # noqa
|
|
7
|
+
from typing import TypedDict
|
|
8
|
+
|
|
9
|
+
import asyncio_dgram
|
|
10
|
+
|
|
11
|
+
from python_rako.bridge import Bridge, BridgeCommanderHTTP, BridgeCommanderUDP # noqa
|
|
12
|
+
from python_rako.const import RAKO_BRIDGE_DEFAULT_PORT, MessageType, RequestType # noqa
|
|
13
|
+
from python_rako.exceptions import RakoBridgeError # noqa
|
|
14
|
+
from python_rako.model import ( # noqa
|
|
15
|
+
BridgeInfo,
|
|
16
|
+
ChannelLight,
|
|
17
|
+
ChannelStatusMessage,
|
|
18
|
+
LevelCache,
|
|
19
|
+
LevelCacheItem,
|
|
20
|
+
Light,
|
|
21
|
+
RoomChannel,
|
|
22
|
+
RoomLight,
|
|
23
|
+
SceneCache,
|
|
24
|
+
SceneStatusMessage,
|
|
25
|
+
UnsupportedMessage,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
_LOGGER = logging.getLogger(__name__)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BridgeDescription(TypedDict, total=False):
|
|
32
|
+
host: str
|
|
33
|
+
port: int
|
|
34
|
+
name: str
|
|
35
|
+
mac: str
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
async def discover_bridge() -> BridgeDescription:
|
|
39
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
40
|
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
|
41
|
+
server = await asyncio_dgram.from_socket(sock)
|
|
42
|
+
await server.send(b"D", ("255.255.255.255", RAKO_BRIDGE_DEFAULT_PORT))
|
|
43
|
+
msg, (host, port) = await server.recv()
|
|
44
|
+
bridge_description: BridgeDescription = {"host": host, "port": port}
|
|
45
|
+
try:
|
|
46
|
+
name, mac = msg.decode("utf8").split()
|
|
47
|
+
bridge_description["name"] = name
|
|
48
|
+
bridge_description["mac"] = mac
|
|
49
|
+
except ValueError:
|
|
50
|
+
raise ValueError(f"Couldn't interpret discovery response message: {msg}")
|
|
51
|
+
return bridge_description
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def main() -> None:
|
|
55
|
+
bridge_desc: BridgeDescription = asyncio.run(discover_bridge())
|
|
56
|
+
print(bridge_desc)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
main()
|