Metadata-Version: 2.1
Name: ceems
Version: 0.3.0
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 the service is running
```
systemctl status ceems
```

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

### Config file

Make sure that `/etc/ceems/ceems.conf` contains the correct configuration. an example is given in `/misc/etc/``

+ PV-Forecaster

    forecaster_user= nymea
    forecaster_password = <forecaster_password>
    forecaster_active = True
    forecaster_min_power=1.0


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

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

+ dynamic tariffs

    mqtt_host=localhost
    mqtt_port=4104
    mqtt_username=leaflet
    mqtt_password=leaflet
    mqtt_topic_subscribe=event/ntp_el-1
    mqtt_topic_ack=event/ntp-1  

+ S3 Logging

    aws_access_key_id=
    aws_secret_access_key=
    s3-bucket=


# 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


### Local and Pipeline Test

A test script is started in the CI pipeline on commit. The script requires the image created by `Dockerfile`, which (if changed) can be built and uploaded to the gitlab image repository through a manual trigger in the pipeline. 

Additionally, the test script can be run locally. 

```
./tests/test_module.sh 
```



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

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

Request to the Energy Broker with this example

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

Send a Charging Plan with this example

    echo -n '{"jsonrpc": "2.0", "method": "sendChargingPlan","params":[{"startTime": "2023-09-19T08:10:00", "slots": [{"duration": "04:00:00.0","maximumPower": 7000}]},{}], "id": 1}' | nc localhost 20001


### Testing JSONRPC calls manually

The following scripts can be used to test if the JSONRPC calls to CEEBUS are working correctly, without ceems. These scripts shall help to ensure, that we have correct knowledge about the JSONRPC calls and the expected results.

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





