S2 Protocol Python Wrapper
Project description
This Python package implements the message validation for the EN50491-12-2 “S2” standard for home and building energy management. This implementation is based on the asyncapi description of the protocol provided in the s2-ws-json repository.
Currently, the package supports the common and FILL RATE BASED CONTROL types and messages.
To Install
You can install this package using pip or any Python dependency manager that collects the packages from Pypi:
pip install s2-python
The packages on Pypi may be found here
Mypy support
s2-python uses pydantic at its core to define the various S2 messages. As such, the pydantic mypy plugin is required for type checking to succeed.
Add to your pyproject.toml:
[tool.mypy]
plugins = ['pydantic.mypy']
Example
from s2python.common import PowerRange, CommodityQuantity
# create s2 messages as Python objects
number_range = PowerRange(
start_of_range=4.0,
end_of_range=5.0,
commodity_quantity=CommodityQuantity.ELECTRIC_POWER_L1,
)
# serialize s2 messages
number_range.to_json()
# deserialize s2 messages
json_str = '{"start_of_range": 4.0, "end_of_range": 5.0, "commodity_quantity": "ELECTRIC.POWER.L1"}'
PowerRange.from_json(json_str)
Development
For development, you can install the required dependencies using the following command:
pip install -e .[testing,development]
The tests can be run using tox:
tox
To build the package, you can use tox as well:
tox -e build,clean
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file s2_python-0.3.0.tar.gz
.
File metadata
- Download URL: s2_python-0.3.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3ac6dc142772a21ace20bd136208ed9d40c7bdeaab03c5dc9ce304aaade4b3f |
|
MD5 | 33a5c84413b9e1b63d3e93104f741a47 |
|
BLAKE2b-256 | 9aeef3acf6ea12f0cbd8af37d3ef233ef771d4faac66577a9b8572683860a3d7 |
File details
Details for the file s2_python-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: s2_python-0.3.0-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5ffc4a86afd3af5172ffc19c21873c86d1fc1dd92c43fb7290324f381f0ccbb |
|
MD5 | 90884e25f3edfb2080931bb3e12fae54 |
|
BLAKE2b-256 | 7ce3301c99e632cf886300925b0fc5a1b3a0d7933643f5abc7eb9171519068e6 |