Metadata-Version: 2.1
Name: ceems
Version: 0.1.5
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: License :: proprietary and confidential
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).


## Setup or Update

```
apt update
apt install ceems
``` 

Check if service is running
```
systemctl status ceems
```

Check installed version with
```
pip3 show ceems
```

### Config file

Make sure that `/etc/ceems/ceems.conf` contains the correct configuration.

+ PV-Forecaster

    forecaster-user= nymea
    forecaster-password = <forecaster_password>


+ MQTT-Logging to Influx/Grafana (see IoT-Admin)

    mqtt_log_hemsID=<hemsID>
    mqtt_log_host=amqp.services.consolinno.de
    mqtt_log_port=8883
    mqtt_log_user= <user>
    mqtt_log_password= <password>


## Develop

## Debian package

### Update Version Number

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

### Trigger Build
All commits in `main`-branch are automatically built and uploaded to Consolinno Debian Repo (dev).

To Trigger a qa-build, merge into branch `pre-prod` and start pipeline in GitLab (`Build->Pipelines->Run Pipeline`).


## Testing
### Dev Testing of ceems-Daemon 
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 

    ./IEC_client --port 4102 --hostname localhost --write allCLS1
    ./IEC_client --port 4102 --write addLimitCLS1 1600


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





