twist-innovation-api 0.0.1__py3-none-any.whl

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.
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: twist-innovation-api
3
+ Version: 0.0.1
4
+ Summary: Python library to talk to the twist-innovation api
5
+ Home-page: https://github.com/twist-innovation/twist-innovation-api
6
+ Author: Sibrecht Goudsmedt
7
+ Author-email: sibrecht.goudsmedt@twist-innovation.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: author
15
+ Dynamic: author-email
16
+ Dynamic: classifier
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: home-page
20
+ Dynamic: license-file
21
+ Dynamic: requires-python
22
+ Dynamic: summary
23
+
24
+ # Twist Innovation API
25
+
26
+ ## Overview
27
+ This is the **Twist Innovation API** – a Python library for interacting with Twist Innovation devices via MQTT.
28
+
29
+ ## Installation
30
+
31
+ You can install this package using pip:
32
+
33
+ ```bash
34
+ pip install twist-innovation-api
35
+ ```
36
+
37
+ Alternatively, if you have cloned the repository, install it locally:
38
+
39
+ ```bash
40
+ pip install .
41
+ ```
42
+
43
+ ## Contributing the Project (without installing in pip)
44
+ This repo can be tested with the include main.py. With this main.py, you don't need to install the package. If you just want to install and use, go to Usage
45
+ ### Configuration
46
+ Before running the project, you need to create a configuration file named `config.yaml` in the project root directory. This file should contain your MQTT broker details:
47
+
48
+ ```yaml
49
+ mqtt_broker: "your-mqtt-broker.com"
50
+ mqtt_user: "your-username"
51
+ mqtt_pass: "your-password"
52
+ mqtt_port: 1883 # Default MQTT port
53
+ ```
54
+ ### Testing
55
+ You can test the package using the included `main.py` file. Ensure you have a valid `config.yaml` file set up, then run:
56
+
57
+ ```bash
58
+ python main.py
59
+ ```
60
+
61
+ ### Building
62
+ To build the package, run the following command:
63
+
64
+ ```bash
65
+ python -m build
66
+ ```
67
+
68
+ ### Pushing to PyPi
69
+ To push the package to PyPi, run the following command:
70
+
71
+ ```bash
72
+ twine upload dist/*
73
+ ```
74
+
75
+
76
+
77
+ ## Usage
78
+
79
+ Import the package in your Python scripts:
80
+
81
+ ```python
82
+ from twist import TwistAPI, TwistModel
83
+
84
+ # Other includes for this example
85
+ import asyncio
86
+ from typing import Callable
87
+
88
+ # Initialize the mqtt broker here and define the functions needed
89
+
90
+ # Create a callback function
91
+ callback_f: Callable[[str, str], None] | None = None
92
+
93
+ # Callback function when a Mqtt message is received from the broker and forward it to the twist API
94
+ def on_message(client, userdata, msg):
95
+ if callback_f is not None:
96
+ callback_f(msg.topic, msg.payload.decode())
97
+
98
+ # Publish message to the broker
99
+ def mqtt_publish(topic, payload):
100
+ pass
101
+
102
+ # Subscribe to a topic from the broker
103
+ def mqtt_subscribe(topic, callback):
104
+ global callback_f
105
+ callback_f = callback
106
+
107
+ # Callback function when a model received an update
108
+ def on_model_update(model: TwistModel):
109
+ model.print_context()
110
+
111
+ async def main():
112
+ twist_api = TwistAPI(8, on_model_update)
113
+ twist_api.add_mqtt(mqtt_publish, mqtt_subscribe)
114
+ twist_model_list: list[TwistModel] = await twist_api.search_models()
115
+
116
+ while True:
117
+ await asyncio.sleep(1)
118
+
119
+
120
+ if __name__ == "__main__":
121
+ asyncio.run(main())
122
+ ```
123
+
124
+ ## License
125
+ This project is licensed under the **GPL-3.0 License**. See the `LICENSE` file for details.
126
+
127
+ ## Contributing
128
+ Contributions are welcome! Feel free to submit a pull request or open an issue.
129
+
130
+ ## Contact
131
+ For any issues or questions, reach out via the [GitHub Issues](https://github.com/twist-innovation/twist-innovation-api/issues).
132
+
@@ -0,0 +1,16 @@
1
+ twist/TwistAPI.py,sha256=pHUXI-ToF3zda9Q2gQzlHg73G0q7MWwgXGqz23PmRyY,3645
2
+ twist/TwistCbShutter.py,sha256=fOZ2ELxmsuH7seLmxvZmSpuSIzn6D6kKyIxtVYU0ZUI,1100
3
+ twist/TwistDevice.py,sha256=dByOL6v3k36Dz-QMsbgZQCr8JdxxxyOWhfn4G1Xzpaw,1409
4
+ twist/TwistLight.py,sha256=H1guYXWgZYCV5b-pNnQalAp5-_aI6N6db5aEoJhEoEs,3034
5
+ twist/TwistLouvre.py,sha256=ewYLO7nXFSEq7XtitXJW0VlLRv3_-iwsg8BhA5bOUMw,3128
6
+ twist/TwistModel.py,sha256=MFN3Bs0g3k_FKwTL40c3iHsy4mqXpUvLQpSfGybwaGY,2877
7
+ twist/TwistRgb.py,sha256=ui4DiKJ91TRTXQz3s6J_Wl-Ue7tKIGnY1FuMTZP_RFs,3340
8
+ twist/TwistSensor.py,sha256=AvuhlUejthAdQXsNA6MAS6NyKwpvLs4UiEa3P1mwqOE,1093
9
+ twist/TwistTypes.py,sha256=wsp-lnkaU70wNdoKWOWcnsq89vBheBYmM31ZXW3FMRw,2166
10
+ twist/Variants.py,sha256=SFAZ7bSmTRomPspOfU1qNWEW-htRuyhTKuyGKK9Qh54,1369
11
+ twist/__init__.py,sha256=gf8GHc9utiG0vD8GP3IfzLFHAG-ev1TXBIm0XUHxy38,201
12
+ twist_innovation_api-0.0.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
13
+ twist_innovation_api-0.0.1.dist-info/METADATA,sha256=2BIzSO_NZ2Dygs_hUdVg5PfeUcX3riO1tr4txoerIxY,3499
14
+ twist_innovation_api-0.0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
15
+ twist_innovation_api-0.0.1.dist-info/top_level.txt,sha256=mkoeBkRPFodjnd-3UDf9YndjTQ6Sriz-EKSI4nQ7brs,6
16
+ twist_innovation_api-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+