Metadata-Version: 2.1
Name: ceems
Version: 0.1.3
Summary: Consolinno Energy Managment System utilizing EEBUS
Home-page: UNKNOWN
Author: Leonhard Heizinger, Andreas Penzkofer, Christian Ohnesorg
Author-email: l.heizinger@consolinno.de, a.penzkofer@consolinno.de, c.ohnesorg@consolinno.de
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# cEEMS [cēms] [:speaker:](https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=ceems)

Daemon tool `ceemsd` to answer JSON-RPC requests from the [EEBUS-Daemon](https://gitlab.consolinno-it.de/leafletfirmware/eebus/consolinno-eebus-daemon).

## Technical documentation

The technical documentation is found [here](docu.asciidoc).

## ToDo
* add `update-ca-certificates -f` to some debian install process (rules?)

## Setup and Update

```
apt update
apt install ceems
```

+ Make sure that `/etc/ceems/ceems.conf` contains the correct configuration (incl. Login-data for IoT-Admin).

+ Make sure ca-certificates are up-to-date.
```
update-ca-certificates -f

```




## Dev

## Debian package

update version in `debian/changelog`
```
dch -v 0.0.4 -D experimental "release message..."
```
update version in `setup.py` (-> `version="0.1.2"`)



### Testing

TODO: Automated Testing

#### for testing package (in parent folder)
```
pip install -e .
```

start CEEMS-daemon
```
python3 src/ceems/ceemsd.py -d
```


#### Energy Guard

Start the IEC services `IEC_server` and `Schedule Manager` from [ffnstb-ie-61850](https://gitlab.consolinno-it.de/leafletfirmware/cls-firmware/fnnstb-iec-61850).

Then write schedule data by starting the client with 

    sudo ./IEC_client --port 4102 --hostname localhost --write all

Request to the Energy Guard with this example

    echo -n '{"jsonrpc": "2.0", "method": "requestPowerLimitationCurve","params":[{},{},{}], "id": 1}' | nc localhost 20001

#### Energy Broker

Install [mosquitto](https://mosquitto.org/). 

    apt install mosquitto mosquitto-clients procps

Receive incentive data via MQTT by starting the sim with 

    py src/mqtt-sim/sim.py

Request to the Energy Broker with this example

    echo -n '{"jsonrpc": "2.0", "method": "requestIncentiveTable","params":[{"slotCountMax": 17}], "id": 1}' | nc localhost 20001

#### Manual testing

In /src/ceems/ run
 
    python3 -m unittest test_module.py

To test the mqqt part of the energy broker, in /src/mqqt-sim/ follow the instructions in this [README](src/mqqt-sim/README.md).

#### Testing JSONRPC calls manually

    cd src/ceems/test_scripts
    .request_plim_table.sh
    .request_incentive_table.sh
    .request_send_charging_plan.sh


## MQTT-Logging to IoT-Admin

The MQTT login-data is storec in `/etc/ceems/ceems.conf`. The content should be

    forecaster-user =  nymea
    forecaster-password = yyy


