|
6 | 6 |
|
7 | 7 | Enapter software development kit for Python. |
8 | 8 |
|
| 9 | +## Features |
| 10 | + |
| 11 | +1. [Standalone |
| 12 | + Devices](https://v3.developers.enapter.com/docs/standalone/introduction) |
| 13 | + framework. |
| 14 | +2. [MQTT |
| 15 | + API](https://v3.developers.enapter.com/reference/device_integration/mqtt_api/) |
| 16 | + client. |
| 17 | +3. [HTTP API](https://v3.developers.enapter.com/reference/http/intro) client. |
| 18 | + |
9 | 19 | ## Installation |
10 | 20 |
|
11 | | -This project uses [semantic versioning](https://semver.org/). |
| 21 | +> [!IMPORTANT] |
| 22 | +> Make sure you are using Python 3.11+. |
12 | 23 |
|
13 | | -The API is still under development and may change at any time. It is |
14 | | -recommended to pin the version during installation. |
| 24 | +> [!WARNING] |
| 25 | +> The API is still under development and may change at any time. It is |
| 26 | +> recommended to pin the version during installation. |
15 | 27 |
|
16 | | -Latest from PyPI: |
| 28 | +From PyPI: |
17 | 29 |
|
18 | 30 | ```bash |
19 | | -pip install enapter==0.11.3 |
| 31 | +pip install enapter==0.12.0 |
20 | 32 | ``` |
21 | 33 |
|
22 | 34 | ## Usage |
23 | 35 |
|
24 | | -Checkout [examples](examples). |
25 | | - |
26 | | -## Implementing your own VUCM |
27 | | - |
28 | | -### Device Telemetry and Properties |
29 | | - |
30 | | -Every method of `enapter.vucm.Device` subclass decorated with |
31 | | -`enapter.vucm.device_task` decorator is considered a _device task_. When such a |
32 | | -device is started, all of its tasks are started as well. Device tasks are |
33 | | -started in random order and are being executed concurrently in the background. |
34 | | -If a device task returns or raises an exception, device routine is terminated. |
35 | | -A typical use of the task is to run a periodic job to send device telemetry and |
36 | | -properties. |
37 | | - |
38 | | -In order to send telemetry and properties define two corresponding device |
39 | | -tasks. It is advised (but is not obligatory) to send telemetry every **1 |
40 | | -second** and to send properties every **10 seconds**. |
41 | | - |
42 | | -Examples: |
43 | | - |
44 | | -- [wttr-in](examples/vucm/wttr-in) |
45 | | - |
46 | | -### Device Command Handlers |
47 | | - |
48 | | -Every method of `enapter.vucm.Device` subclass decorated with |
49 | | -`enapter.vucm.device_command` is considered a _device command handler_. Device |
50 | | -command handlers receive the same arguments as described in device Blueprint |
51 | | -manifest and can optionally return a payload as `enapter.types.JSON`. |
52 | | - |
53 | | -In order to handle device commands define corresponding device command |
54 | | -handlers. |
55 | | - |
56 | | -Examples: |
| 36 | +Check out examples: |
57 | 37 |
|
58 | | -- [zhimi-fan-za5](examples/vucm/zhimi-fan-za5) |
| 38 | +- [Standalone Devices](examples/standalone) |
| 39 | +- [MQTT API](examples/mqtt) |
| 40 | +- [HTTP API](examples/http) |
59 | 41 |
|
60 | | -### Device Alerts |
| 42 | +They provide a good overview of available features and should give you enough |
| 43 | +power to get started. |
61 | 44 |
|
62 | | -Device alerts are stored in `self.alerts`. It is a usual Python `set`, so you |
63 | | -can add an alert using `alerts.add`, remove an alert `alerts.remove` and clear |
64 | | -alerts using `alerts.clear`. |
| 45 | +> [!TIP] |
| 46 | +> Don't hesitate to peek into the source code - it is supposed to be easy to |
| 47 | +> follow. |
65 | 48 |
|
66 | | -Alerts are sent only as part of telemetry, so in order to report device alert, |
67 | | -use `send_telemetry` with any payload. |
| 49 | +## Help |
68 | 50 |
|
69 | | -## Running your own VUCM via Docker |
70 | | - |
71 | | -A simple Dockerfile can be: |
72 | | - |
73 | | -``` |
74 | | -FROM python:3.10-alpine3.16 |
75 | | -
|
76 | | -WORKDIR /app |
77 | | -
|
78 | | -RUN python -m venv .venv |
79 | | -COPY requirements.txt requirements.txt |
80 | | -RUN .venv/bin/pip install -r requirements.txt |
81 | | -
|
82 | | -COPY script.py script.py |
83 | | -
|
84 | | -CMD [".venv/bin/python", "script.py"] |
85 | | -``` |
86 | | - |
87 | | -:information_source: If you are using [Enapter |
88 | | -Gateway](https://handbook.enapter.com/software/gateway_software/) and running |
89 | | -Linux, you should connect your containers to `host` network |
90 | | -:information_source:: |
91 | | - |
92 | | -```bash |
93 | | -docker run --network host ... |
94 | | -``` |
| 51 | +If you feel lost or confused, reach us in |
| 52 | +[Discord](https://discord.com/invite/TCaEZs3qpe) or just [file a |
| 53 | +bug](https://github.com/Enapter/python-sdk/issues/new). We'd be glad to help. |
0 commit comments