TISApi 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.
Files changed (33) hide show
  1. tisapi-0.0.1/.github/workflows/publish.yml +50 -0
  2. tisapi-0.0.1/.gitignore +5 -0
  3. tisapi-0.0.1/.vscode/c_cpp_properties.json +18 -0
  4. tisapi-0.0.1/.vscode/launch.json +24 -0
  5. tisapi-0.0.1/.vscode/settings.json +59 -0
  6. tisapi-0.0.1/.vscode/tasks.json +53 -0
  7. tisapi-0.0.1/LICENSE +21 -0
  8. tisapi-0.0.1/PKG-INFO +60 -0
  9. tisapi-0.0.1/README.md +46 -0
  10. tisapi-0.0.1/dev/pump_version.py +53 -0
  11. tisapi-0.0.1/pyproject.toml +25 -0
  12. tisapi-0.0.1/requirements.txt +126 -0
  13. tisapi-0.0.1/src/TISApi/BytesHelper.py +65 -0
  14. tisapi-0.0.1/src/TISApi/DiscoveryHelpers.py +6 -0
  15. tisapi-0.0.1/src/TISApi/Protocols/__init__.py +23 -0
  16. tisapi-0.0.1/src/TISApi/Protocols/udp/AckCoordinator.py +22 -0
  17. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketDispatcher.py +20 -0
  18. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketExtractor.py +21 -0
  19. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketHandlers/ControlResponseHandler.py +32 -0
  20. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketHandlers/DiscoveryFeedbackHandler.py +10 -0
  21. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketHandlers/UpdateResponseHandler.py +18 -0
  22. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketHandlers/__init__.py +0 -0
  23. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketProtocol.py +49 -0
  24. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketReceiver.py +35 -0
  25. tisapi-0.0.1/src/TISApi/Protocols/udp/PacketSender.py +78 -0
  26. tisapi-0.0.1/src/TISApi/Protocols/udp/ProtocolHandler.py +424 -0
  27. tisapi-0.0.1/src/TISApi/Protocols/udp/UpdateCoordinator.py +0 -0
  28. tisapi-0.0.1/src/TISApi/Protocols/udp/__init__.py +0 -0
  29. tisapi-0.0.1/src/TISApi/__init__.py +0 -0
  30. tisapi-0.0.1/src/TISApi/api.py +125 -0
  31. tisapi-0.0.1/src/TISApi/crc.py +306 -0
  32. tisapi-0.0.1/src/TISApi/shared.py +1 -0
  33. tisapi-0.0.1/tests/test.py +64 -0
@@ -0,0 +1,50 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*" # Triggers on tags like v0.0.1
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v3
14
+
15
+ - name: Extract version from tag
16
+ shell: bash
17
+ run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
18
+
19
+ - name: Update pyproject.toml version
20
+ run: |
21
+ sed -i "s/^version =.*/version = \"${VERSION#v}\"/" pyproject.toml
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v4
25
+ with:
26
+ python-version: "3.12"
27
+
28
+ - name: Install dependencies
29
+ run: |
30
+ python -m pip install --upgrade pip
31
+ pip install build twine wheel
32
+ pip install -r requirements.txt
33
+
34
+ - name: Build package
35
+ run: python -m build
36
+
37
+ - name: Sign the distributions
38
+ env:
39
+ GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
40
+ run: |
41
+ echo "$GPG_SIGNING_KEY" | gpg --import
42
+ gpg --detach-sign --armor dist/*.tar.gz
43
+ gpg --detach-sign --armor dist/*.whl
44
+
45
+ - name: Publish to PyPI
46
+ env:
47
+ TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
48
+ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
49
+ run: |
50
+ twine upload --skip-existing dist/* dist/*.asc
@@ -0,0 +1,5 @@
1
+ .env
2
+ dist
3
+ mykey.pub
4
+ mykey.asc
5
+ *.pyc
@@ -0,0 +1,18 @@
1
+ {
2
+ "configurations": [
3
+ {
4
+ "name": "windows-gcc-x64",
5
+ "includePath": [
6
+ "${workspaceFolder}/**"
7
+ ],
8
+ "compilerPath": "gcc",
9
+ "cStandard": "${default}",
10
+ "cppStandard": "${default}",
11
+ "intelliSenseMode": "windows-gcc-x64",
12
+ "compilerArgs": [
13
+ ""
14
+ ]
15
+ }
16
+ ],
17
+ "version": 4
18
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "C/C++ Runner: Debug Session",
6
+ "type": "cppdbg",
7
+ "request": "launch",
8
+ "args": [],
9
+ "stopAtEntry": false,
10
+ "externalConsole": true,
11
+ "cwd": "d:/TIS/dev/TISApi",
12
+ "program": "d:/TIS/dev/TISApi/build/Debug/outDebug",
13
+ "MIMode": "gdb",
14
+ "miDebuggerPath": "gdb",
15
+ "setupCommands": [
16
+ {
17
+ "description": "Enable pretty-printing for gdb",
18
+ "text": "-enable-pretty-printing",
19
+ "ignoreFailures": true
20
+ }
21
+ ]
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "C_Cpp_Runner.cCompilerPath": "gcc",
3
+ "C_Cpp_Runner.cppCompilerPath": "g++",
4
+ "C_Cpp_Runner.debuggerPath": "gdb",
5
+ "C_Cpp_Runner.cStandard": "",
6
+ "C_Cpp_Runner.cppStandard": "",
7
+ "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
8
+ "C_Cpp_Runner.useMsvc": false,
9
+ "C_Cpp_Runner.warnings": [
10
+ "-Wall",
11
+ "-Wextra",
12
+ "-Wpedantic",
13
+ "-Wshadow",
14
+ "-Wformat=2",
15
+ "-Wcast-align",
16
+ "-Wconversion",
17
+ "-Wsign-conversion",
18
+ "-Wnull-dereference"
19
+ ],
20
+ "C_Cpp_Runner.msvcWarnings": [
21
+ "/W4",
22
+ "/permissive-",
23
+ "/w14242",
24
+ "/w14287",
25
+ "/w14296",
26
+ "/w14311",
27
+ "/w14826",
28
+ "/w44062",
29
+ "/w44242",
30
+ "/w14905",
31
+ "/w14906",
32
+ "/w14263",
33
+ "/w44265",
34
+ "/w14928"
35
+ ],
36
+ "C_Cpp_Runner.enableWarnings": true,
37
+ "C_Cpp_Runner.warningsAsError": false,
38
+ "C_Cpp_Runner.compilerArgs": [],
39
+ "C_Cpp_Runner.linkerArgs": [],
40
+ "C_Cpp_Runner.includePaths": [],
41
+ "C_Cpp_Runner.includeSearch": [
42
+ "*",
43
+ "**/*"
44
+ ],
45
+ "C_Cpp_Runner.excludeSearch": [
46
+ "**/build",
47
+ "**/build/**",
48
+ "**/.*",
49
+ "**/.*/**",
50
+ "**/.vscode",
51
+ "**/.vscode/**"
52
+ ],
53
+ "C_Cpp_Runner.useAddressSanitizer": false,
54
+ "C_Cpp_Runner.useUndefinedSanitizer": false,
55
+ "C_Cpp_Runner.useLeakSanitizer": false,
56
+ "C_Cpp_Runner.showCompilationTime": false,
57
+ "C_Cpp_Runner.useLinkTimeOptimization": false,
58
+ "C_Cpp_Runner.msvcSecureNoWarnings": false
59
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "label": "Update Version",
6
+ "type": "shell",
7
+ "command": "python",
8
+ "args": [
9
+ "${workspaceFolder}/dev/pump_version.py",
10
+ "${workspaceFolder}/pyproject.toml"
11
+ ],
12
+ "problemMatcher": [],
13
+ "detail": "Interactively update the version in pyproject.toml."
14
+ },
15
+ {
16
+ "label": "Build Package",
17
+ "type": "shell",
18
+ "command": "python",
19
+ "args": [
20
+ "-m",
21
+ "build"
22
+ ],
23
+ "problemMatcher": [],
24
+ "detail": "Build the latest version of the package.",
25
+ "group": {
26
+ "kind": "build",
27
+ "isDefault": true
28
+ }
29
+ },
30
+ {
31
+ "label": "Upload Package",
32
+ "type": "shell",
33
+ "command": "twine",
34
+ "args": [
35
+ "upload",
36
+ "dist/*"
37
+ ],
38
+ "problemMatcher": [],
39
+ "detail": "Upload the latest version of the package to PyPI."
40
+ },
41
+ {
42
+ "label": "Update, Build, and Upload",
43
+ "dependsOn": [
44
+ "Update Version",
45
+ "Build Package",
46
+ "Upload Package"
47
+ ],
48
+ "dependsOrder": "sequence",
49
+ "problemMatcher": [],
50
+ "detail": "Update the version, build the package, and upload it to PyPI."
51
+ }
52
+ ]
53
+ }
tisapi-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
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.
tisapi-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: TISApi
3
+ Version: 0.0.1
4
+ Summary: A library for TIS Control
5
+ Project-URL: Homepage, https://github.com/IbrahimMohamed2001
6
+ Project-URL: Issues, https://github.com/IbrahimMohamed2001/issues
7
+ Author-email: Ibrahim Mohamed <ibrali2001.ia@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.11
13
+ Description-Content-Type: text/markdown
14
+
15
+ # TISApi
16
+
17
+ ![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
18
+ ![Version 0.5.14](https://img.shields.io/badge/version-0.5.14-blue)
19
+ ![License MIT](https://img.shields.io/badge/license-MIT-green)
20
+ ![Python](https://img.shields.io/badge/python-3.11+-orange)
21
+ ![signed](https://img.shields.io/badge/signed-yes-green)
22
+
23
+ TISApi is a powerful Python package for controlling TIS devices. It provides a simple and intuitive API for interacting with TIS devices, making it easy to integrate TIS devices into your Python applications.
24
+
25
+ ## Features
26
+
27
+ - ✅ Fully Supports Asynchronous Operations
28
+ - ✅ Flawless feedback mechanism to prevent data loss
29
+ - ✅ Debounce mechanism to prevent multiple commands from being sent for protection
30
+ - ✅ Easy to use API for controlling TIS devices
31
+ - ✅ Clean and simple codebase
32
+ - ✅ Ready to integrate with Home Assistant
33
+
34
+ ## Installation
35
+
36
+ You can install TISApi by adding it to your Manifest file or by using pip. Here's how you can install it using pip:
37
+
38
+ ```bash
39
+ pip install TISApi
40
+ ```
41
+
42
+ ## Verifying Package Signatures
43
+
44
+ This package is signed with GPG to ensure authenticity. Follow these steps to verify:
45
+
46
+ 1. **Install GPG**: Ensure you have GPG installed (`gpg --version`).
47
+ 2. **Get My Public Key**:
48
+ - Import from a keyserver: `gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 97DADF7C6008FBCEB93506624A93BA55D2B45649`
49
+ - Import it: `gpg --import mykey.pub`
50
+ 3. **Download Files**: Get the `.tar.gz`, `.whl`, and `.asc` files from PyPI or GitHub Releases.
51
+ 4. **Verify**:
52
+
53
+ ```bash
54
+ gpg --verify TISApi-0.5.14.tar.gz.asc TISApi-0.5.14.tar.gz
55
+ gpg --verify TISApi-0.5.14-py3-none-any.whl.asc TISApi-0.5.14-py3-none-any.whl
56
+ ```
57
+
58
+ ## License
59
+
60
+ TISApi is licensed under the MIT license. See the [LICENSE](https://github.com/IbrahimMohamed2001/TISApi/blob/main/LICENSE) file for details.
tisapi-0.0.1/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # TISApi
2
+
3
+ ![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
4
+ ![Version 0.5.14](https://img.shields.io/badge/version-0.5.14-blue)
5
+ ![License MIT](https://img.shields.io/badge/license-MIT-green)
6
+ ![Python](https://img.shields.io/badge/python-3.11+-orange)
7
+ ![signed](https://img.shields.io/badge/signed-yes-green)
8
+
9
+ TISApi is a powerful Python package for controlling TIS devices. It provides a simple and intuitive API for interacting with TIS devices, making it easy to integrate TIS devices into your Python applications.
10
+
11
+ ## Features
12
+
13
+ - ✅ Fully Supports Asynchronous Operations
14
+ - ✅ Flawless feedback mechanism to prevent data loss
15
+ - ✅ Debounce mechanism to prevent multiple commands from being sent for protection
16
+ - ✅ Easy to use API for controlling TIS devices
17
+ - ✅ Clean and simple codebase
18
+ - ✅ Ready to integrate with Home Assistant
19
+
20
+ ## Installation
21
+
22
+ You can install TISApi by adding it to your Manifest file or by using pip. Here's how you can install it using pip:
23
+
24
+ ```bash
25
+ pip install TISApi
26
+ ```
27
+
28
+ ## Verifying Package Signatures
29
+
30
+ This package is signed with GPG to ensure authenticity. Follow these steps to verify:
31
+
32
+ 1. **Install GPG**: Ensure you have GPG installed (`gpg --version`).
33
+ 2. **Get My Public Key**:
34
+ - Import from a keyserver: `gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 97DADF7C6008FBCEB93506624A93BA55D2B45649`
35
+ - Import it: `gpg --import mykey.pub`
36
+ 3. **Download Files**: Get the `.tar.gz`, `.whl`, and `.asc` files from PyPI or GitHub Releases.
37
+ 4. **Verify**:
38
+
39
+ ```bash
40
+ gpg --verify TISApi-0.5.14.tar.gz.asc TISApi-0.5.14.tar.gz
41
+ gpg --verify TISApi-0.5.14-py3-none-any.whl.asc TISApi-0.5.14-py3-none-any.whl
42
+ ```
43
+
44
+ ## License
45
+
46
+ TISApi is licensed under the MIT license. See the [LICENSE](https://github.com/IbrahimMohamed2001/TISApi/blob/main/LICENSE) file for details.
@@ -0,0 +1,53 @@
1
+ import toml
2
+ import sys
3
+
4
+
5
+ def bump_version(version, part):
6
+ major, minor, patch = map(int, version.split("."))
7
+ if part == "major":
8
+ major += 1
9
+ minor = 0
10
+ patch = 0
11
+ elif part == "minor":
12
+ minor += 1
13
+ patch = 0
14
+ elif part == "patch":
15
+ patch += 1
16
+ else:
17
+ raise ValueError("Part must be 'major', 'minor', or 'patch'")
18
+ return f"{major}.{minor}.{patch}"
19
+
20
+
21
+ def update_version_file(file_path, part):
22
+ with open(file_path, "r") as f:
23
+ data = toml.load(f)
24
+
25
+ current_version = data["project"]["version"]
26
+ new_version = bump_version(current_version, part)
27
+ data["project"]["version"] = new_version
28
+
29
+ with open(file_path, "w") as f:
30
+ toml.dump(data, f)
31
+
32
+ print(f"Version updated from {current_version} to {new_version}")
33
+
34
+
35
+ if __name__ == "__main__":
36
+ if len(sys.argv) != 2:
37
+ print("Usage: python update_version_interactive.py <path_to_pyproject.toml>")
38
+ sys.exit(1)
39
+
40
+ file_path = sys.argv[1]
41
+ print("Select the part to bump:")
42
+ print("1. Major")
43
+ print("2. Minor")
44
+ print("3. Patch")
45
+ choice = input("Enter the number (1/2/3): ").strip()
46
+
47
+ part_map = {"1": "major", "2": "minor", "3": "patch"}
48
+ part = part_map.get(choice)
49
+ if not part:
50
+ print("Invalid choice. Must be 1, 2, or 3.")
51
+ sys.exit(1)
52
+
53
+ update_version_file(file_path, part)
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "TISApi"
7
+ version = "0.0.1"
8
+ description = "A library for TIS Control"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ classifiers = [
12
+ "Programming Language :: Python :: 3",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Operating System :: POSIX :: Linux",
15
+ ]
16
+ [[project.authors]]
17
+ name = "Ibrahim Mohamed"
18
+ email = "ibrali2001.ia@gmail.com"
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/IbrahimMohamed2001"
22
+ Issues = "https://github.com/IbrahimMohamed2001/issues"
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/TISApi"]
@@ -0,0 +1,126 @@
1
+ 2to3==1.0
2
+ acme==2.8.0
3
+ aiodns==3.2.0
4
+ aiofiles==24.1.0
5
+ aiohttp==3.9.5
6
+ aiohttp-cors==0.7.0
7
+ aiohttp-fast-url-dispatcher==0.3.0
8
+ aiohttp-isal==0.2.0
9
+ aiohttp-session==2.12.0
10
+ aiooui==0.1.5
11
+ aiosignal==1.3.1
12
+ anyio==4.3.0
13
+ astral==2.2
14
+ async-interrupt==1.1.1
15
+ async-timeout==4.0.3
16
+ asyncio==3.4.3
17
+ atomicwrites==1.4.1
18
+ atomicwrites-homeassistant==1.4.1
19
+ attrs==23.2.0
20
+ awesomeversion==24.2.0
21
+ bcrypt==4.1.2
22
+ bleak==0.21.1
23
+ bleak-retry-connector==3.5.0
24
+ bluetooth-adapters==0.19.0
25
+ bluetooth-auto-recovery==1.4.1
26
+ bluetooth-data-tools==1.19.0
27
+ boto3==1.34.88
28
+ botocore==1.34.88
29
+ btsocket==0.2.0
30
+ build==1.2.1
31
+ certifi==2024.2.2
32
+ cffi==1.16.0
33
+ charset-normalizer==3.3.2
34
+ ciso8601==2.3.1
35
+ colorama==0.4.6
36
+ cryptography==42.0.5
37
+ dbus-fast==2.21.1
38
+ docutils==0.21.2
39
+ ecdsa==0.19.0
40
+ envs==1.4
41
+ fnv-hash-fast==0.5.0
42
+ fnvhash==0.1.0
43
+ frozenlist==1.4.1
44
+ gmqtt==0.6.14
45
+ greenlet==3.0.3
46
+ h11==0.14.0
47
+ ha-philipsjs==3.1.1
48
+ habluetooth==2.8.0
49
+ hass-nabucasa==0.78.0
50
+ home-assistant-bluetooth==1.12.0
51
+ httpcore==1.0.5
52
+ httpx==0.27.0
53
+ idna==3.6
54
+ ifaddr==0.2.0
55
+ importlib_metadata==7.1.0
56
+ isal==1.6.1
57
+ jaraco.classes==3.4.0
58
+ jaraco.context==5.3.0
59
+ jaraco.functools==4.0.1
60
+ Jinja2==3.1.3
61
+ jmespath==1.0.1
62
+ josepy==1.14.0
63
+ keyring==25.2.1
64
+ lru-dict==1.3.0
65
+ markdown-it-py==3.0.0
66
+ MarkupSafe==2.1.5
67
+ mdurl==0.1.2
68
+ more-itertools==10.2.0
69
+ multidict==6.0.5
70
+ nh3==0.2.17
71
+ numpy==1.26.4
72
+ orjson==3.10.1
73
+ packaging==24.0
74
+ paho-mqtt==1.6.0
75
+ pillow==10.3.0
76
+ pkginfo==1.11.0
77
+ psutil==5.9.8
78
+ psutil-home-assistant==0.0.1
79
+ pyasn1==0.6.0
80
+ pycares==4.4.0
81
+ pycognito==2023.5.0
82
+ pycparser==2.22
83
+ Pygments==2.18.0
84
+ PyJWT==2.8.0
85
+ pyOpenSSL==24.1.0
86
+ pyproject_hooks==1.1.0
87
+ pyRFC3339==1.1
88
+ PyRIC==0.1.6.3
89
+ python-dateutil==2.9.0.post0
90
+ python-dotenv==1.0.1
91
+ python-jose==3.3.0
92
+ python-slugify==8.0.4
93
+ pytz==2024.1
94
+ PyYAML==6.0.1
95
+ readme_renderer==43.0
96
+ requests==2.31.0
97
+ requests-toolbelt==1.0.0
98
+ rfc3986==2.0.0
99
+ rich==13.7.1
100
+ rsa==4.9
101
+ ruff==0.4.1
102
+ s3transfer==0.10.1
103
+ setuptools==68.2.2
104
+ six==1.16.0
105
+ slugify==0.0.1
106
+ sniffio==1.3.1
107
+ snitun==0.36.2
108
+ SQLAlchemy==2.0.29
109
+ text-unidecode==1.3
110
+ TISControlProtocol==0.5.11
111
+ tiscontrolv2==0.0.14
112
+ toml==0.10.2
113
+ tqdm==4.66.2
114
+ twine==5.1.0
115
+ typing_extensions==4.11.0
116
+ uart-devices==0.1.0
117
+ ulid-transform==0.9.0
118
+ urllib3==1.26.18
119
+ usb-devices==0.4.5
120
+ voluptuous==0.13.1
121
+ voluptuous-serialize==2.6.0
122
+ watchdog==4.0.0
123
+ wheel==0.41.2
124
+ yarl==1.9.4
125
+ zipp==3.19.2
126
+
@@ -0,0 +1,65 @@
1
+ import binascii
2
+ from TISApi.crc import checkCRC, packCRC
3
+
4
+
5
+ def bytes2hex(data, rtype=[]):
6
+ """A helper function to parse bytes to hex
7
+
8
+ :param data: the raw bytes array
9
+ :type data: bytes array
10
+ :param rtype: determine return type whether list of ints or single hex str, defaults to []
11
+ :type rtype: list, optional
12
+ :return: list of ints or hex string
13
+ :rtype: list | str
14
+ """
15
+ hex_string = binascii.hexlify(data).decode()
16
+ hex_list = [int(hex_string[i : i + 2], 16) for i in range(0, len(hex_string), 2)]
17
+ if isinstance(rtype, list):
18
+ return hex_list
19
+ else:
20
+ return hex_string
21
+
22
+
23
+ def build_packet(
24
+ operation_code: list,
25
+ ip_address: str,
26
+ destination_mac: str = "AA:AA:AA:AA:AA:AA:AA:AA",
27
+ source_mac: str = "CB:CB:CB:CB:CB:CB:CB:CB",
28
+ device_id: list = [],
29
+ source_device_id: list = [0x01, 0xFE],
30
+ additional_packets: list = [],
31
+ header="SMARTCLOUD",
32
+ ):
33
+
34
+ # test if all params are loaded
35
+ ip_bytes = [int(part) for part in ip_address.split(".")]
36
+ header_bytes = [ord(char) for char in header]
37
+ source_mac = [int(part, 16) for part in source_mac.split(":")]
38
+ destination_mac = [int(part, 16) for part in destination_mac.split(":")]
39
+ # TODO: modify length
40
+ # length = 21 + len(additional_packets)
41
+ length = 11 + len(additional_packets)
42
+ packet = (
43
+ ip_bytes
44
+ + header_bytes
45
+ + [0xAA, 0xAA]
46
+ + [length]
47
+ # + source_mac
48
+ + source_device_id
49
+ + [0xFF, 0xFE]
50
+ + operation_code
51
+ # + destination_mac
52
+ + device_id
53
+ + additional_packets
54
+ )
55
+ packet = packCRC(packet)
56
+ return packet
57
+
58
+
59
+ def decode_mac(mac: list):
60
+ return ":".join([f"{byte:02X}" for byte in mac])
61
+
62
+
63
+ def int_to_8_bit_binary(number):
64
+ binary_string = bin(number)[2:]
65
+ return binary_string.zfill(8)[::-1]
@@ -0,0 +1,6 @@
1
+ DEVICE_APPLIANCES = {
2
+ (0x1B, 0xBA): {
3
+ "name": "RCU-8OUT-8IN",
4
+ "appliances": {"switch": 8},
5
+ }
6
+ }
@@ -0,0 +1,23 @@
1
+ from asyncio import get_event_loop, AbstractEventLoop
2
+ import socket
3
+ from TISApi.Protocols.udp.PacketProtocol import PacketProtocol
4
+ from homeassistant.core import HomeAssistant
5
+
6
+ loop = get_event_loop()
7
+
8
+
9
+ async def setup_udp_protocol(
10
+ sock: socket,
11
+ loop: AbstractEventLoop,
12
+ udp_ip: str,
13
+ udp_port: int,
14
+ hass: HomeAssistant,
15
+ ) -> tuple[socket.socket, PacketProtocol]:
16
+ transport, protocol = await loop.create_datagram_endpoint(
17
+ lambda: PacketProtocol(sock, udp_ip, udp_port, hass),
18
+ remote_addr=(udp_ip, udp_port),
19
+ local_addr=("0.0.0.0", udp_port),
20
+ allow_broadcast=True,
21
+ reuse_port=True,
22
+ )
23
+ return transport, protocol
@@ -0,0 +1,22 @@
1
+ import logging
2
+ import asyncio
3
+ from TISApi.shared import ack_events
4
+ from typing import Union
5
+
6
+
7
+ class AckCoordinator:
8
+ def __init__(self):
9
+ self.ack_events = ack_events
10
+
11
+ def create_ack_event(self, unique_id: Union[str, tuple]) -> asyncio.Event:
12
+ logging.error(f"creating ack event for {unique_id}")
13
+ event = asyncio.Event()
14
+ self.ack_events[unique_id] = event
15
+ return event
16
+
17
+ def get_ack_event(self, unique_id: Union[str, tuple]) -> Union[asyncio.Event, None]:
18
+ return self.ack_events.get(unique_id)
19
+
20
+ def remove_ack_event(self, unique_id: Union[str, tuple]) -> None:
21
+ if unique_id in self.ack_events:
22
+ del self.ack_events[unique_id]
@@ -0,0 +1,20 @@
1
+ from homeassistant.core import HomeAssistant
2
+ import logging
3
+
4
+
5
+ class PacketDispatcher:
6
+ def __init__(self, hass: HomeAssistant, OPERATIONS_DICT: dict):
7
+ self.hass = hass
8
+ self.operations_dict = OPERATIONS_DICT
9
+
10
+ async def dispatch_packet(self, info):
11
+ try:
12
+ packet_handler = self.operations_dict.get(
13
+ tuple(info["operation_code"]), "unknown operation"
14
+ )
15
+ if packet_handler != "unknown operation":
16
+ await packet_handler(self.hass, info)
17
+ else:
18
+ logging.error(f"unknown operation code: {info['operation_code']}")
19
+ except Exception as e:
20
+ logging.error(f"error in dispatching packet: {e} , {info}")