This service implements the Device business logic for Smart Grids DTDL use case.
- It sends a message to the Neighborhood entity in case Devices are with low battery.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip freeze > requirements.txt
docker build -t ktwin/device-service:0.1 .
docker compose up -d
kind load docker-image ktwin/device-service:0.1
Expected behavior: it process the event and in case of low battery level, it sends a notification to the neighborhood entity.
curl --request POST \
--url http://localhost:8081/ \
--header 'Content-Type: application/json' \
--header 'ce-id: 123' \
--header 'ce-source: device-001' \
--header 'ce-specversion: 1.0' \
--header 'ce-time: 2021-10-16T18:54:04.924Z' \
--header 'ce-type: ktwin.real.device' \
--data '{
"batteryLevel": 10,
"dateObserved": "2023-07-01T01:11:34.39Z"
}'
The following object is stored in event store: