Skip to content

Python wrapper of the EN-50491-12-2 standard

License

Notifications You must be signed in to change notification settings

SES-fortiss/s2-python

 
 

Repository files navigation

Python Wrapper for S2 Flexibility Protocol

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

About

Python wrapper of the EN-50491-12-2 standard

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.6%
  • Shell 0.4%