Uses a Raspberry pi to monitor the water level in my sump and will send an alert when the water is higher than a certain threshold. The purpose of this tool is to be alerted in case of a sump pump failure so I can react before the basement is flooded.
The Docker image can be built with the following command
python setup.py bdist_wheel && \
docker build . -t matthewjsporter/sump-level-sensor:latest
- use
aws configure
to login to aws. - since this project relies on having GPIO pins, we can run locally by mocking the gpio pins using the
mocksump
entrypoint.
docker run -v ${HOME}/.aws:/root/.aws matthewjsporter/sump-level-sensor:latest mocksump
Unit tests can be ran using setup.py
python setup.py test
Deployments are done through github actions. The workflow will deploy the image to Dockerhub. Watchtower is deployed on the raspberry pi where it will automatically pull down the latest version and redeploy. notifications are sent to a SNS message queue and is created using CloudFormation.
docker push matthewjsporter/sump-level-sensor:latest
cloudformation will run during the deployment pipeline but can be ran from local using the following command.
aws cloudformation update-stack --stack-name sump-level-sensor --template-body file://aws/cloudformation.yml --parameters ParameterKey=EmailParameter,ParameterValue=<email> ParameterKey=SMSParameter,ParameterValue=<phone>
One time installation on the raspberry pi is needed
- Configure AWS credentials
sudo systemctl edit docker
and add the following content
[Service]
Environment="AWS_ACCESS_KEY_ID=<access-key>"
Environment="AWS_SECRET_ACCESS_KEY=<secret-key>"
add the following to /home/pi/.profile
export AWS_ACCESS_KEY_ID=<access-key>
export AWS_SECRET_ACCESS_KEY=<secret-key>
export AWS_DEFAULT_REGION=us-east-1
Use docker compose
to start the containers
curl https://github.com/raw/matthew-js-porter/sump-level-sensor/master/docker-compose.yml > docker-compose.yml
docker-compose up -d
after the initial installation is done, watchtower will install updates automatically.
Docker image scanning is done using Snyk as part of the deployment pipeline and results can be viewed on the github action logs. You can run a scan locally by running this command.
snyk container test --exclude-base-image-vulns --file=Dockerfile --policy-path=.snyk matthewjsporter/sump-level-sensor:latest
OSS image scanning is done using Snyk as part of the deployment pipeline and results can be viewed on the github action logs. You can run a scan locally by running this command.
snyk test --file=sump_level_sensor.egg-info/requires.txt --package-manager=pip
Sonar scans are done as part of the deployment pipeline and results can be viewed on the github action logs. Results can also be found on Sonarcloud.
Circuit design can be found in circuit-diagram.fzz