pysyncleo 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.
- pysyncleo-0.1.0/.editorconfig +114 -0
- pysyncleo-0.1.0/.github/workflows/lint.yml +32 -0
- pysyncleo-0.1.0/.github/workflows/release.yml +27 -0
- pysyncleo-0.1.0/.gitignore +10 -0
- pysyncleo-0.1.0/.pre-commit-config.yaml +9 -0
- pysyncleo-0.1.0/.python-version +1 -0
- pysyncleo-0.1.0/LICENSE +21 -0
- pysyncleo-0.1.0/PKG-INFO +21 -0
- pysyncleo-0.1.0/README.md +5 -0
- pysyncleo-0.1.0/example.py +138 -0
- pysyncleo-0.1.0/pyproject.toml +34 -0
- pysyncleo-0.1.0/src/pysyncleo/__init__.py +0 -0
- pysyncleo-0.1.0/src/pysyncleo/commands.py +564 -0
- pysyncleo-0.1.0/src/pysyncleo/const.py +4 -0
- pysyncleo-0.1.0/src/pysyncleo/encoding.py +136 -0
- pysyncleo-0.1.0/src/pysyncleo/enums.py +92 -0
- pysyncleo-0.1.0/src/pysyncleo/models.py +71 -0
- pysyncleo-0.1.0/src/pysyncleo/transport.py +213 -0
- pysyncleo-0.1.0/src/pysyncleo/utils.py +14 -0
- pysyncleo-0.1.0/uv.lock +348 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
indent_size = 4
|
|
7
|
+
indent_style = space
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
max_line_length = 120
|
|
10
|
+
tab_width = 4
|
|
11
|
+
ij_continuation_indent_size = 8
|
|
12
|
+
ij_formatter_off_tag = @formatter:off
|
|
13
|
+
ij_formatter_on_tag = @formatter:on
|
|
14
|
+
ij_formatter_tags_enabled = false
|
|
15
|
+
ij_smart_tabs = false
|
|
16
|
+
ij_wrap_on_typing = false
|
|
17
|
+
|
|
18
|
+
[.editorconfig]
|
|
19
|
+
ij_editorconfig_align_group_field_declarations = false
|
|
20
|
+
ij_editorconfig_space_after_colon = false
|
|
21
|
+
ij_editorconfig_space_after_comma = true
|
|
22
|
+
ij_editorconfig_space_before_colon = false
|
|
23
|
+
ij_editorconfig_space_before_comma = false
|
|
24
|
+
ij_editorconfig_spaces_around_assignment_operators = true
|
|
25
|
+
|
|
26
|
+
[*.json]
|
|
27
|
+
indent_size = 2
|
|
28
|
+
tab_width = 2
|
|
29
|
+
ij_json_keep_blank_lines_in_code = 0
|
|
30
|
+
ij_json_keep_indents_on_empty_lines = false
|
|
31
|
+
ij_json_keep_line_breaks = true
|
|
32
|
+
ij_json_space_after_colon = true
|
|
33
|
+
ij_json_space_after_comma = true
|
|
34
|
+
ij_json_space_before_colon = true
|
|
35
|
+
ij_json_space_before_comma = false
|
|
36
|
+
ij_json_spaces_within_braces = false
|
|
37
|
+
ij_json_spaces_within_brackets = false
|
|
38
|
+
ij_json_wrap_long_lines = false
|
|
39
|
+
|
|
40
|
+
[{*.py,*.pyw}]
|
|
41
|
+
ij_python_align_collections_and_comprehensions = true
|
|
42
|
+
ij_python_align_multiline_imports = true
|
|
43
|
+
ij_python_align_multiline_parameters = true
|
|
44
|
+
ij_python_align_multiline_parameters_in_calls = true
|
|
45
|
+
ij_python_blank_line_at_file_end = true
|
|
46
|
+
ij_python_blank_lines_after_imports = 1
|
|
47
|
+
ij_python_blank_lines_after_local_imports = 0
|
|
48
|
+
ij_python_blank_lines_around_class = 1
|
|
49
|
+
ij_python_blank_lines_around_method = 1
|
|
50
|
+
ij_python_blank_lines_around_top_level_classes_functions = 2
|
|
51
|
+
ij_python_blank_lines_before_first_method = 0
|
|
52
|
+
ij_python_call_parameters_new_line_after_left_paren = false
|
|
53
|
+
ij_python_call_parameters_right_paren_on_new_line = false
|
|
54
|
+
ij_python_call_parameters_wrap = normal
|
|
55
|
+
ij_python_dict_alignment = 0
|
|
56
|
+
ij_python_dict_new_line_after_left_brace = false
|
|
57
|
+
ij_python_dict_new_line_before_right_brace = false
|
|
58
|
+
ij_python_dict_wrapping = 1
|
|
59
|
+
ij_python_from_import_new_line_after_left_parenthesis = false
|
|
60
|
+
ij_python_from_import_new_line_before_right_parenthesis = false
|
|
61
|
+
ij_python_from_import_parentheses_force_if_multiline = false
|
|
62
|
+
ij_python_from_import_trailing_comma_if_multiline = false
|
|
63
|
+
ij_python_from_import_wrapping = 1
|
|
64
|
+
ij_python_hang_closing_brackets = false
|
|
65
|
+
ij_python_keep_blank_lines_in_code = 1
|
|
66
|
+
ij_python_keep_blank_lines_in_declarations = 1
|
|
67
|
+
ij_python_keep_indents_on_empty_lines = false
|
|
68
|
+
ij_python_keep_line_breaks = true
|
|
69
|
+
ij_python_method_parameters_new_line_after_left_paren = false
|
|
70
|
+
ij_python_method_parameters_right_paren_on_new_line = false
|
|
71
|
+
ij_python_method_parameters_wrap = normal
|
|
72
|
+
ij_python_new_line_after_colon = false
|
|
73
|
+
ij_python_new_line_after_colon_multi_clause = true
|
|
74
|
+
ij_python_optimize_imports_always_split_from_imports = false
|
|
75
|
+
ij_python_optimize_imports_case_insensitive_order = false
|
|
76
|
+
ij_python_optimize_imports_join_from_imports_with_same_source = false
|
|
77
|
+
ij_python_optimize_imports_sort_by_type_first = true
|
|
78
|
+
ij_python_optimize_imports_sort_imports = true
|
|
79
|
+
ij_python_optimize_imports_sort_names_in_from_imports = false
|
|
80
|
+
ij_python_space_after_comma = true
|
|
81
|
+
ij_python_space_after_number_sign = true
|
|
82
|
+
ij_python_space_after_py_colon = true
|
|
83
|
+
ij_python_space_before_backslash = true
|
|
84
|
+
ij_python_space_before_comma = false
|
|
85
|
+
ij_python_space_before_for_semicolon = false
|
|
86
|
+
ij_python_space_before_lbracket = false
|
|
87
|
+
ij_python_space_before_method_call_parentheses = false
|
|
88
|
+
ij_python_space_before_method_parentheses = false
|
|
89
|
+
ij_python_space_before_number_sign = true
|
|
90
|
+
ij_python_space_before_py_colon = false
|
|
91
|
+
ij_python_space_within_empty_method_call_parentheses = false
|
|
92
|
+
ij_python_space_within_empty_method_parentheses = false
|
|
93
|
+
ij_python_spaces_around_additive_operators = true
|
|
94
|
+
ij_python_spaces_around_assignment_operators = true
|
|
95
|
+
ij_python_spaces_around_bitwise_operators = true
|
|
96
|
+
ij_python_spaces_around_eq_in_keyword_argument = false
|
|
97
|
+
ij_python_spaces_around_eq_in_named_parameter = false
|
|
98
|
+
ij_python_spaces_around_equality_operators = true
|
|
99
|
+
ij_python_spaces_around_multiplicative_operators = true
|
|
100
|
+
ij_python_spaces_around_power_operator = true
|
|
101
|
+
ij_python_spaces_around_relational_operators = true
|
|
102
|
+
ij_python_spaces_around_shift_operators = true
|
|
103
|
+
ij_python_spaces_within_braces = false
|
|
104
|
+
ij_python_spaces_within_brackets = false
|
|
105
|
+
ij_python_spaces_within_method_call_parentheses = false
|
|
106
|
+
ij_python_spaces_within_method_parentheses = false
|
|
107
|
+
ij_python_use_continuation_indent_for_arguments = false
|
|
108
|
+
ij_python_use_continuation_indent_for_collection_and_comprehensions = false
|
|
109
|
+
ij_python_use_continuation_indent_for_parameters = true
|
|
110
|
+
ij_python_wrap_long_lines = false
|
|
111
|
+
|
|
112
|
+
[Pipfile]
|
|
113
|
+
ij_toml_keep_indents_on_empty_lines = false
|
|
114
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: "Lint"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- "main"
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- "main"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
ruff:
|
|
13
|
+
name: "Ruff"
|
|
14
|
+
runs-on: "ubuntu-latest"
|
|
15
|
+
steps:
|
|
16
|
+
- name: "Checkout the repository"
|
|
17
|
+
uses: "actions/checkout@v6"
|
|
18
|
+
|
|
19
|
+
- name: "Install uv"
|
|
20
|
+
uses: astral-sh/setup-uv@v8.2.0
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
cache-dependency-glob: "uv.lock"
|
|
24
|
+
|
|
25
|
+
- name: "Install requirements"
|
|
26
|
+
run: uv sync --all-extras --dev
|
|
27
|
+
|
|
28
|
+
- name: "Lint"
|
|
29
|
+
run: uv run ruff check .
|
|
30
|
+
|
|
31
|
+
- name: "Format"
|
|
32
|
+
run: uv run ruff format . --check
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
on:
|
|
2
|
+
release:
|
|
3
|
+
types: [published]
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v6
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v8.2.0
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
cache-dependency-glob: "uv.lock"
|
|
22
|
+
|
|
23
|
+
- name: Build package
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Publish
|
|
27
|
+
run: uv publish
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
pysyncleo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dmitriy
|
|
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.
|
pysyncleo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pysyncleo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Basic library for working with Syncleo UDP devices
|
|
5
|
+
Project-URL: Repository, https://github.com/DeKaN/pysyncleo.git
|
|
6
|
+
Author: DeKaN
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Requires-Dist: cryptography>=44.0.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# pySyncleo
|
|
18
|
+
|
|
19
|
+
Library to control devices using Syncleo IoT (Rusclimate/Polaris) UDP protocol.
|
|
20
|
+
|
|
21
|
+
Simple example can be found in `example.py`
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import logging
|
|
3
|
+
from typing import Dict
|
|
4
|
+
|
|
5
|
+
from zeroconf import ServiceStateChange
|
|
6
|
+
from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconf
|
|
7
|
+
|
|
8
|
+
from pysyncleo.commands import CmdInitDiagnostic
|
|
9
|
+
from pysyncleo.const import SYNCLEO_MDNS_TYPE
|
|
10
|
+
from pysyncleo.enums import ConnectionState
|
|
11
|
+
from pysyncleo.models import SyncleoUdpDevice
|
|
12
|
+
from pysyncleo.transport import SyncleoConnection, TransportManager
|
|
13
|
+
|
|
14
|
+
logging.basicConfig(
|
|
15
|
+
level=logging.DEBUG,
|
|
16
|
+
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
17
|
+
datefmt="%H:%M:%S",
|
|
18
|
+
)
|
|
19
|
+
_LOGGER = logging.getLogger("syncleo_example")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AsyncDiscoveryListener:
|
|
23
|
+
"""Non-blocking listener for mDNS state changes."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, queue: asyncio.Queue):
|
|
26
|
+
self.queue = queue
|
|
27
|
+
|
|
28
|
+
def async_on_service_state_change(
|
|
29
|
+
self, zeroconf, service_type: str, name: str, state_change: ServiceStateChange
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Called synchronously by zeroconf, but spawns an async task to resolve info."""
|
|
32
|
+
if state_change is ServiceStateChange.Added:
|
|
33
|
+
asyncio.create_task(self.resolve_service(zeroconf, service_type, name))
|
|
34
|
+
|
|
35
|
+
async def resolve_service(self, zeroconf, service_type: str, name: str):
|
|
36
|
+
info = AsyncServiceInfo(service_type, name)
|
|
37
|
+
|
|
38
|
+
await info.async_request(zeroconf, 3000)
|
|
39
|
+
|
|
40
|
+
if info and info.parsed_addresses():
|
|
41
|
+
ip_address = info.parsed_addresses()[0]
|
|
42
|
+
|
|
43
|
+
self.queue.put_nowait(
|
|
44
|
+
{
|
|
45
|
+
"ip": ip_address,
|
|
46
|
+
"port": info.port,
|
|
47
|
+
"txt": info.decoded_properties,
|
|
48
|
+
"name": name,
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def state_update_callback(cmd):
|
|
54
|
+
if hasattr(cmd, "value"):
|
|
55
|
+
_LOGGER.info(f"🟢 DEVICE STATE UPDATE: {cmd.command_type.name} = {cmd.value}")
|
|
56
|
+
else:
|
|
57
|
+
_LOGGER.info(f"🟢 DEVICE STATE UPDATE: {cmd.command_type.name}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def interact_with_device(conn):
|
|
61
|
+
for _ in range(10):
|
|
62
|
+
if conn.state == ConnectionState.CONNECTED:
|
|
63
|
+
break
|
|
64
|
+
await asyncio.sleep(0.5)
|
|
65
|
+
|
|
66
|
+
if conn.state != ConnectionState.CONNECTED:
|
|
67
|
+
_LOGGER.error(f"❌ Handshake timed out for {conn.device.inet_address[0]}")
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
_LOGGER.info(f"✅ Secure Session Established with {conn.device.inet_address[0]}!")
|
|
71
|
+
await asyncio.sleep(1.5)
|
|
72
|
+
|
|
73
|
+
_LOGGER.info("📡 Requesting deep network diagnostics...")
|
|
74
|
+
await conn.send_command(CmdInitDiagnostic(mode=0))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def main():
|
|
78
|
+
loop = asyncio.get_running_loop()
|
|
79
|
+
|
|
80
|
+
manager = TransportManager()
|
|
81
|
+
transport, _ = await loop.create_datagram_endpoint(
|
|
82
|
+
lambda: manager, local_addr=("0.0.0.0", 0)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
discovery_queue = asyncio.Queue()
|
|
86
|
+
listener = AsyncDiscoveryListener(discovery_queue)
|
|
87
|
+
aiozc = AsyncZeroconf()
|
|
88
|
+
|
|
89
|
+
browser = AsyncServiceBrowser(
|
|
90
|
+
aiozc.zeroconf,
|
|
91
|
+
[SYNCLEO_MDNS_TYPE],
|
|
92
|
+
handlers=[listener.async_on_service_state_change],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
_LOGGER.info("🔍 Searching for Syncleo devices on the local network...")
|
|
96
|
+
active_connections: Dict[str, "SyncleoConnection"] = {}
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
while True:
|
|
100
|
+
discovered = await discovery_queue.get()
|
|
101
|
+
ip = discovered["ip"]
|
|
102
|
+
|
|
103
|
+
if ip in active_connections:
|
|
104
|
+
continue
|
|
105
|
+
|
|
106
|
+
_LOGGER.info(
|
|
107
|
+
f"💡 Found Device: {discovered['name']} at {ip}:{discovered['port']}"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
device = SyncleoUdpDevice.from_zeroconf(
|
|
111
|
+
ip, discovered["port"], discovered["txt"]
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
conn = manager.register_device(device)
|
|
115
|
+
if not conn:
|
|
116
|
+
continue
|
|
117
|
+
|
|
118
|
+
conn.on_state_updated = state_update_callback
|
|
119
|
+
active_connections[ip] = conn
|
|
120
|
+
|
|
121
|
+
await conn.connect()
|
|
122
|
+
asyncio.create_task(interact_with_device(conn))
|
|
123
|
+
|
|
124
|
+
except asyncio.CancelledError:
|
|
125
|
+
pass
|
|
126
|
+
finally:
|
|
127
|
+
_LOGGER.info("Closing sockets and network listeners...")
|
|
128
|
+
|
|
129
|
+
await browser.async_cancel()
|
|
130
|
+
await aiozc.async_close()
|
|
131
|
+
transport.close()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if __name__ == "__main__":
|
|
135
|
+
try:
|
|
136
|
+
asyncio.run(main())
|
|
137
|
+
except KeyboardInterrupt:
|
|
138
|
+
print("\nExiting script...")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pysyncleo"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Basic library for working with Syncleo UDP devices"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "DeKaN" }
|
|
8
|
+
]
|
|
9
|
+
keywords = []
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.13"
|
|
18
|
+
dependencies = [
|
|
19
|
+
"cryptography>=44.0.0"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Repository = "https://github.com/DeKaN/pysyncleo.git"
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["hatchling"]
|
|
27
|
+
build-backend = "hatchling.build"
|
|
28
|
+
|
|
29
|
+
[dependency-groups]
|
|
30
|
+
dev = [
|
|
31
|
+
"pre-commit>=4.5.1",
|
|
32
|
+
"ruff>=0.15.5",
|
|
33
|
+
"zeroconf>=0.149.16"
|
|
34
|
+
]
|
|
File without changes
|