gridworks-scada
GridWorks SCADA for space heating
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Repository
GridWorks SCADA for space heating
Basic Info
Statistics
- Stars: 5
- Watchers: 5
- Forks: 2
- Open Issues: 39
- Releases: 0
Metadata Files
README.md
GridWorks SCADA
========
This code is intended for running a heat pump thermal storage space heating system in a house, and doing this transactively. That means the heating system is capable of dynamically responding to local electric grid conditions and buying energy at the lowest cost times, while keeping the house warm. We believe this repo may be instrumental in effectively and efficiently reaching a low-carbon future. For an architectural overview of the code, and why it has something to do with a low-carbon future, please go here.
This code is part of a larger framework. In particular it assumes there is a cloud-based actor which it refers to as the AtomicTNode (short for Atomic Transactive Node) that is calling the shots on its control decisions most of the time. In addition, the code is structured in an actor-based way, with a collection of actors each responsible for an important but limited set of functionality communicating to each other via messages. For a more specific description of both how these internal actors work with each other and how this repo fits into the larger transactive energy framework please go here; this page describes typical sequences of messages between relevant actors in the system.
We are indebted to Efficiency Maine, who spearheaded and funded the initial pilot using this code. As per the requirements of the initial pilot, the code is intended to: 1) run on a raspberry Pi 4; and 2) to be able to use a variety of off-the-shelf actuating and sensing devices.
For information on setting up an SD card that will run this code on a Pi 4 with the correct configuration and attached devices, please go here
Local Demo setup
Follow the directions below for creating a dev environment (assumes mac or Pi).
In one terminal window:
cd spaceheat
python run_local.py
WE NEED A BETTER LOCAL DEV DEMO
Creating a Dev environment for macos or Pi
- Use python 3.10.6
- .gitignore includes gwspaceheat/venv for virtualenv so from gwspaceheat directory:
python -m venv venvsource venv/bin/activatepip install -r requirements/dev.txt
Run the tests from the root directory of the repo with:
pytest
A hardware layout file is necessary to run the scada locally. Find the default path the layout file with:
python -c "import config; print(config.Paths().hardware_layout)"
For initial experiments the test layout file can be used. The test layout file is located at:
tests/config/hardware-layout.json
Display the hardware layout with:
python gw_spaceheat/show_layout.py
Display current settings with:
python gw_spaceheat/show_settings.py
There are some scratch notes on Pi-related setup (like enabling interfaces) in docs/pi_setup.md
Adding libraries
- If you are going to add libraries, install pip-tools to your venv:
python -m pip install pip-tools- If you want to add a new library used in all contexts, then go to gw_spaceheat/requirements, add it to base.in and run
pip-compile --output-file=base.txt base.inpip-compile --output-file=dev.txt dev.inpip-compile --output-file=drivers.txt drivers.in
The .in files clarify the key modules (including which ones are important to pin and which ones can be set to the latest release) and then the corresponding .txt files are generated via pip-tools. This means we always run on pinned requirements (from the .txt files) and can typically upgrade to the latest release, except for cases where the code requires a pinned older version.
The pip-tools also allow for building layers of requirements on top of each other. This allows us to have development tools that are not needed in production to show up for the first time in dev.txt, for example (like the pip-tool itself).
Handling secrets and config variables
SETTING UP SECRETS.
Configuration variables (secret or otherwise) use dotenv module in a gitignored .env file, copied over from .env-template. These are accessed via config.ScadaSettings.
Setting up MQTT
See instructions here to set up a local MQTT broker using Mosquitto.
Static analsyis with ruff
Ruff is installed via the test and dev requirements. You can run it with:
ruff check
Ruff is not run in CI or in pre-commit, since the code will not currently pass.
Ruff is provided primarily for visual feedback in the IDE. Ruff is configured
in pyproject.toml.
Static analysis in Visual Studio Code
Visual Studio Code will provide visual feedback on code that does not pass ruff.
To use this functionality, the ruff plugin for Visual Studio code must be installed. We recommend:
- Installing the ruff extension.
- Disabling it.
- Enabling for workspaces in which you want to use it, such as this one.
More static analysis
More rigid ruff rules can be applied by modifying pyproject.toml. Gwproto, for example, uses many more rules.
Typechecking feedback can be applied in the IDE by enabling Pylance type checking inside vscode. Change that in user not workspace settings since much of the code will currently fail.
TLS
TLS is used by default. Follow these instructions to set up a local self-signed Certificate Authority to create test certificates and to create certificates for the Mosquitto broker. Note that this section is relevant if you will connect to the Mosquitto broker from a Raspberry PI.
Create a certificate for the test ATN
shell
gwcert key add --certs-dir $HOME/.config/gridworks/atn/certs scada_mqtt
cp $HOME/.local/share/gridworks/ca/ca.crt $HOME/.config/gridworks/atn/certs/scada_mqtt
Create a certificate for test Scada
shell
gwcert key add --certs-dir $HOME/.config/gridworks/scada/certs gridworks_mqtt
cp $HOME/.local/share/gridworks/ca/ca.crt $HOME/.config/gridworks/scada/certs/gridworks_mqtt
Test generated certificates
In one terminal run: ```shell
mosquittosub -h localhost -p 8883 -t foo \ --cafile $HOME/.config/gridworks/atn/certs/scadamqtt/ca.crt \ --cert $HOME/.config/gridworks/atn/certs/scadamqtt/scadamqtt.crt \ --key $HOME/.config/gridworks/atn/certs/scadamqtt/private/scadamqtt.pem
In another terminal run:
shell
mosquittopub -h localhost -p 8883 -t foo -m '{"bar":1}' \
--cafile $HOME/.config/gridworks/scada/certs/gridworksmqtt/ca.crt \
--cert $HOME/.config/gridworks/scada/certs/gridworksmqtt/gridworksmqtt.crt \
--key $HOME/.config/gridworks/scada/certs/gridworksmqtt/private/gridworksmqtt.pem
```
Verify you see {"bar":1} in the first window.
Configuring a Scada with keys that can be used with the GridWorks MQTT broker.
Use getkeys.py to
create and copy TLS to keys to a scada such that it can communicate with the actual GridWorks MQTT broker. For details
run:
shell
python gw_spaceheat/getkeys.py --help
The overview of this process is that you need:
1. The ssh key for certbot.
2. rclone installed.
3. An rclone remote configured for your scada.
4. To construct the getkeys.py command line per its help.
Running the code
This command will show information about what scada would do if started locally:
shell
python gw_spaceheat/run_scada.py --dry-run
This command will will start the scada locally:
shell
python gw_spaceheat/run_scada.py
These commands will start the local test ATN:
shell
python tests/atn/run.py
License
Distributed under the terms of the [MIT license][license], this repository is free and open source software.
Contributing
Contributions are very welcome. To learn more, see the [Contributor Guide].
Owner
- Name: GridWorks
- Login: thegridelectric
- Kind: organization
- Email: gridworks@gridworks-consulting.com
- Repositories: 7
- Profile: https://github.com/thegridelectric
GridWorks is an agent-based, scalable and secure system for decarbonizing power grids.
GitHub Events
Total
- Issues event: 1
- Delete event: 20
- Issue comment event: 5
- Push event: 206
- Pull request review comment event: 1
- Pull request review event: 2
- Pull request event: 31
- Create event: 25
Last Year
- Issues event: 1
- Delete event: 20
- Issue comment event: 5
- Push event: 206
- Pull request review comment event: 1
- Pull request review event: 2
- Pull request event: 31
- Create event: 25
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jessica Millar | j****r@g****m | 901 |
| thdfw | t****w@g****m | 472 |
| Andrew Schweitzer | s****2@g****m | 457 |
| stickler-ci | s****t@s****m | 63 |
| Preethi Vaidyanathan | p****i@g****m | 15 |
| Jessica Millar | j****a@j****l | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 1
- Total pull requests: 38
- Average time to close issues: N/A
- Average time to close pull requests: 2 days
- Total issue authors: 1
- Total pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.05
- Merged pull requests: 32
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 36
- Average time to close issues: N/A
- Average time to close pull requests: 2 days
- Issue authors: 1
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.06
- Merged pull requests: 30
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- anschweitzer (2)
Pull Request Authors
- jessicamillar (30)
- anschweitzer (18)
- thdfw (6)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- numpy *
- paho-mqtt *
- pendulum *
- pika ==1.1.0
- python-dotenv *
- pytz *
- numpy ==1.22.4
- paho-mqtt ==1.6.1
- pendulum ==2.1.2
- pika ==1.1.0
- python-dateutil ==2.8.2
- python-dotenv ==0.20.0
- pytz ==2022.1
- pytzdata ==2020.1
- six ==1.16.0
- ipython ==8.0.0
- isort *
- pip-tools *
- pymodbus *
- pyserial *
- smbus2 *
- numpy ==1.22.4
- paho-mqtt ==1.6.1
- pendulum ==2.1.2
- pika ==1.1.0
- pymodbus ==2.5.3
- pyserial ==3.5
- python-dateutil ==2.8.2
- python-dotenv ==0.20.0
- pytz ==2022.1
- pytzdata ==2020.1
- six ==1.16.0
- smbus2 ==0.4.1
- black *
- coverage *
- mypy *
- nose *
- pytest *
- actions/checkout v2 composite
- actions/download-artifact v2 composite
- actions/setup-python v2 composite
- actions/upload-artifact v3 composite
- canastro/copy-file-action master composite
- codecov/codecov-action v3.1.0 composite
- namoshek/mosquitto-github-action v1 composite
- appnope ==0.1.3 development
- asttokens ==2.0.5 development
- attrs ==21.4.0 development
- backcall ==0.2.0 development
- black ==22.3.0 development
- build ==0.8.0 development
- certifi ==2022.9.14 development
- charset-normalizer ==2.1.1 development
- click ==8.1.3 development
- commonmark ==0.9.1 development
- coverage ==6.4.1 development
- decorator ==5.1.1 development
- docutils ==0.19 development
- executing ==0.8.3 development
- gridworks-protocol ==0.2.2 development
- idna ==3.4 development
- iniconfig ==1.1.1 development
- ipython ==8.0.0 development
- isort ==5.10.1 development
- jedi ==0.18.1 development
- matplotlib-inline ==0.1.3 development
- mypy ==0.961 development
- mypy-extensions ==0.4.3 development
- nose ==1.3.7 development
- numpy ==1.22.4 development
- packaging ==21.3 development
- paho-mqtt ==1.6.1 development
- parso ==0.8.3 development
- pathspec ==0.9.0 development
- pendulum ==2.1.2 development
- pep517 ==0.12.0 development
- pexpect ==4.8.0 development
- pickleshare ==0.7.5 development
- pika ==1.1.0 development
- pip-tools ==6.9.0 development
- platformdirs ==2.5.2 development
- pluggy ==1.0.0 development
- prompt-toolkit ==3.0.29 development
- ptyprocess ==0.7.0 development
- pure-eval ==0.2.2 development
- py ==1.11.0 development
- pydantic ==1.10.2 development
- pygments ==2.12.0 development
- pymodbus ==2.5.3 development
- pyparsing ==3.0.9 development
- pyserial ==3.5 development
- pytest ==7.1.2 development
- pytest-asyncio ==0.19.0 development
- pytest-sugar ==0.9.5 development
- python-dateutil ==2.8.2 development
- python-dotenv ==0.20.0 development
- pytz ==2022.1 development
- pytzdata ==2020.1 development
- requests ==2.28.1 development
- result ==0.8.0 development
- rich ==12.5.1 development
- rich-cli ==1.8.0 development
- rich-rst ==1.1.7 development
- six ==1.16.0 development
- smbus2 ==0.4.1 development
- stack-data ==0.2.0 development
- termcolor ==1.1.0 development
- textual ==0.1.18 development
- tomli ==2.0.1 development
- traitlets ==5.1.1 development
- typing-extensions ==4.2.0 development
- urllib3 ==1.26.12 development
- wcwidth ==0.2.5 development
- wheel ==0.37.1 development
- xdg ==5.1.1 development
- attrs ==21.4.0 test
- black ==22.3.0 test
- click ==8.1.3 test
- coverage ==6.4.1 test
- iniconfig ==1.1.1 test
- mypy ==0.961 test
- mypy-extensions ==0.4.3 test
- nose ==1.3.7 test
- packaging ==21.3 test
- pathspec ==0.9.0 test
- platformdirs ==2.5.2 test
- pluggy ==1.0.0 test
- py ==1.11.0 test
- pyparsing ==3.0.9 test
- pytest ==7.1.2 test
- pytest-asyncio ==0.19.0 test
- tomli ==2.0.1 test
- typing-extensions ==4.2.0 test