docker-compose build
docker-compose up
- You'll see
meter
andpv_simulator
service failing and restarting, this is fine, they are waiting forrabbitmq
. Oncerabbitmq
is up, they'll start normally - see logs in local
/logs
directory (host log is mapped to container) - see graph plot by opening 'http://127.0.0.1:7005' on your local machine
if port 7005
, 5672
and 15672
are busy on the host, please either free them or change port
mapping in the docker-compose.yml
file
- create virtual environment (python >= 3.7)
- install dependencies:
pip install -r requirements.txt
- make sure rabbitmq is running
- update rabbitmq connection url by exporting it to environment variable
RABBIT_MQ_HOST
or directly updating insettings.py
file - start meter :
python3 -m simulator.services.meter
- start pv_simulator :
python3 -m simulator.services.pv_simulator
- start web :
python3 -m simulator.services.web
- other variable can be controlled by os environment variable provided in settings.py
- meter.py: It simulates power consumption in home and generates random but continuous power and publish it to the broker.
- simulator.py: Reads message from broker and generates simulated power value, adds that simulated value in power meter reading and write it to the file.
- web.py: It shows a plot which plots power meter reading(KW) with time.
Change the rabbitmq hostname to localhost
in settings 'amqp://guest:guest@localhost:5672'
before running the test.
Test can be run as python3 -m pytest
- More test cases can be added.
- Power value plot can be improved further. Also currently plot shows data for current date, one parameter can be added to select date and show reading for that date.