Skip to main content

S2 Protocol Python Wrapper

Project description

PyPI - Version PyPI - Python Version PyPI - License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s2_python-0.5.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

s2_python-0.5.0-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

Details for the file s2_python-0.5.0.tar.gz.

File metadata

  • Download URL: s2_python-0.5.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for s2_python-0.5.0.tar.gz
Algorithm Hash digest
SHA256 53b6a227d11be65fc4b263183310adc1a9b80246599a2d8b8b154416856fa49a
MD5 4aaec657cd6e37260f50fa2598f43b3a
BLAKE2b-256 58e57ba8bc93295c372314672b1c5b7aaccaf4b1799f5ed4fed05871ac09bc3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2_python-0.5.0.tar.gz:

Publisher: ci.yml on flexiblepower/s2-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file s2_python-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: s2_python-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for s2_python-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b18596433ce0d40bff30be9b14d175a372fe8a85b3dce7792c68e9b539ebf0c7
MD5 516563c9c26fa635971bd7b651b99b41
BLAKE2b-256 ae27967b4ac571050ecc1cccf9efeddfe4c1c461c949b96bdfdde7b32b060130

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2_python-0.5.0-py3-none-any.whl:

Publisher: ci.yml on flexiblepower/s2-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page