I always forget to close my garage door and leave it opened overnight, exposing the contents of my garage such as my prized wine collection to the bad guys on the street.
This problem calls for a fancy solution and that is why I've built this Cloud-enabled Garage Door Monitor (you can actually use it on any door, or windows, or anything that opens and closes).
- Magnetic contact switch (door sensor)
- Raspberry Pi Zero W
- Case for the Raspberry Pi Zero W
- Raspberry Pi Offical Power Supply
-
Make python virtualenv for this project
> mkvirtualenv garage-door-monitor
(if garage-door-monitor environment doesn't exist)> workon garage-door-monitor
(if garage-door-monitor environment already exists)> pip install -r dev-requirements.txt
-
Run the script
> python src/garage-door-monitor.py
-
When finished
> deactivate
-
To remove virtualenv for this project
rmvirtualenv garage-door-monitor
> mkvirtualenv garage-door-monitor
or workon garage-door-monitor
> pip install aws-sam-cli
(https://github.com/awslabs/aws-sam-cli#installation)
> scripts/start_localstack.sh
> sam local invoke AlarmSNSToIFTTTNotification -e test/data/sns_event.json --template deployer/garage_door_monitor.yaml --env-vars ${env_vars_json}
> ./deployer/sam_package_upload.py -p <profile> --s3-bucket <artefact-bucket> --s3-prefix <artefact-prefix> --stack-name garage-door-monitor -d
> python deployer/create_door_,monitor_iot_thing.py --name ${door_monitor_thing_name}
-
Install Docker
> curl -sSL https://get.docker.com | sh
> sudo systemctl enable docker
> sudo systemctl start docker
> sudo usermod -aG docker pi
> docker --version
-
Install bootstrap.sh
> cd ${HOME}
> wget https://raw.githubusercontent.com/hingyeung/garage-door-monitor/master/deployer/bootstrap.sh
> chmod +x bootstrap.sh
-
Install systemd script
> cd /etc/systemd/system
> wget https://raw.githubusercontent.com/hingyeung/garage-door-monitor/master/deployer/garage-door-monitor.service
-
Modify
garage-door-monitor.service
to replace placeholders:<IoT_endpoint>
,<AWS_root_cert_file>
,<IoT_cert_file>
,<IoT_cert_private_key_file>
,<certs_dir>
additional_mqtt_server_host
,additional_mqtt_server_port
andadditional_mqtt_topic_prefix
. -
Start the Garage Door Monitor service
> sudo systemctl start garage-door-monitor.service
This script makes sure all previous versions of the Iot policy created by the specified stack are
deleted first, then detach the IoT policy from all IoT certificates, before deleting the stack.
> python deployer/delete_stack.py --stack-name ${stack_name}
Icons made by Freepik from www.flaticon.com.