Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Logo-S2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Python Wrapper for S2 Flexibility Protocol

<div align="center">
<a href="https://s2standard.org"><img src="./Logo-S2.svg" width="200" height="200" /></a>
<div>
<a href="https://pypi.org/project/s2-python/"><img src="https://img.shields.io/pypi/v/s2-python" /></a>
<a href="https://pypi.org/project/s2-python/"><img src="https://img.shields.io/pypi/pyversions/s2-python" /></a>
</div>
<div>
<a href="./LICENSE"><img src="https://img.shields.io/pypi/l/s2-python" /></a>
<a href="https://discord.com/invite/NyFMEPmuDw"><img src="https://img.shields.io/discord/1351281839913832510"></a>
</div>
</div>
<br />

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](https://github.com/flexiblepower/s2-ws-json/) repository.

## To Install
You can install this package using pip or any Python dependency manager that collects the packages from PyPI:

```bash
pip install s2-python
pip install s2-python[ws] # for S2 over WebSockets
```

The packages on PyPI may be found [here](https://pypi.org/project/s2-python/).

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

```toml
[tool.mypy]
plugins = ['pydantic.mypy']
```


## Example

```python
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:
```bash
pip install -e .[testing,development,ws]
```

The tests can be run using tox:
```bash
tox
```

To build the package, you can use tox as well:
```bash
tox -e build,clean
```

## Funding Acknowledgements
This project is co-financed by [TKI-Energie](https://topsectorenergie.nl/nl/maak-kennis-met-tse/tki-energie-en-industrie/) from the Top Consortia for Knowledge and Innovation (TKI) surcharge of
the Ministry of Economic Affairs and Climate Policy.
80 changes: 0 additions & 80 deletions README.rst

This file was deleted.