Skip to content

Commit d400021

Browse files
authored
Merge pull request #21 from Enapter/rnovatorov/dev
Support Platform API v3
2 parents 243631f + 86a8989 commit d400021

File tree

121 files changed

+2122
-1927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+2122
-1927
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
14+
python: ["3.11", "3.12", "3.13", "3.14"]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

.isort.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[settings]
22
known_first_party=enapter
3+
profile=black

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ lint-pyflakes:
2929

3030
.PHONY: lint-mypy
3131
lint-mypy:
32-
pipenv run mypy enapter
32+
pipenv run mypy setup.py
33+
pipenv run mypy tests
34+
pipenv run mypy src/enapter
3335

3436
.PHONY: test
3537
test: run-unit-tests run-integration-tests
@@ -69,7 +71,7 @@ bump-version:
6971
ifndef V
7072
$(error V is not defined)
7173
endif
72-
sed -E -i 's/__version__ = "[0-9]+.[0-9]+.[0-9]+"/__version__ = "$(V)"/g' enapter/__init__.py
74+
sed -E -i 's/__version__ = "[0-9]+.[0-9]+.[0-9]+"/__version__ = "$(V)"/g' src/enapter/__init__.py
7375

7476
grep -E --files-with-matches --recursive 'enapter==[0-9]+.[0-9]+.[0-9]+' examples \
7577
| xargs -n 1 sed -E -i 's/enapter==[0-9]+.[0-9]+.[0-9]+/enapter==$(V)/g'

Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ pytest-asyncio = "*"
1818
pytest-cov = "*"
1919
setuptools = "*"
2020
twine = "*"
21+
types-docker = "*"
22+
types-setuptools = "*"

README.md

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,48 @@
66

77
Enapter software development kit for Python.
88

9+
## Features
10+
11+
- [Standalone
12+
Devices](https://v3.developers.enapter.com/docs/standalone/introduction)
13+
framework.
14+
- [MQTT
15+
API](https://v3.developers.enapter.com/reference/device_integration/mqtt_api/)
16+
client.
17+
- [HTTP API](https://v3.developers.enapter.com/reference/http/intro) client.
18+
919
## Installation
1020

11-
This project uses [semantic versioning](https://semver.org/).
21+
> [!IMPORTANT]
22+
> Make sure you are using Python 3.11+.
1223
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.
1527
16-
Latest from PyPI:
28+
From PyPI:
1729

1830
```bash
19-
pip install enapter==0.11.3
31+
pip install enapter==0.12.0
2032
```
2133

2234
## Usage
2335

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:
5737

58-
- [zhimi-fan-za5](examples/vucm/zhimi-fan-za5)
38+
- [Standalone Devices](examples/standalone)
39+
- [MQTT API](examples/mqtt)
40+
- [HTTP API](examples/http)
5941

60-
### Device Alerts
42+
They provide a good overview of available features and should give you enough
43+
power to get started.
6144

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.
6548
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
6850

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.

enapter/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

enapter/async_/routine.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

enapter/mqtt/api/__init__.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

enapter/mqtt/api/command.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

enapter/mqtt/api/device_channel.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)