Project Requirements

Hardware

  1. A Raspberry Pi.

    • You’ll need a Raspberry PI with Raspberry PI OS or similar installed and reliable internet.

    • I developed and tested this project on a Pi 1Bv2 and a Pi 3.

  2. Contact switches.

    • These are available cheaply on ebay, Amazon or at your local electronics store.

    • Some examples can be found here.

  3. Temperature monitors.

    • Currently, only the DHT11 is supported, but it’s trivial to add support for the DHT22.

    • You can find out more about these sensors here.

  4. Wiring between the switches, temperature sensors and the Raspberry Pi’s GPIO connectors.

    • Find out more about the Pi’s GPIO here.

    • Female jump wires make installing the connections pretty painless. I spliced them to the ends of modular cables (i.e. phone cables) for longer runs.

    • Edit the config.json file to customize your pin outs and integrations.

  5. A USB camera or webcam that’s compatible with motion.

    • Many webcams are compatible and widely available.

Python

Supports Python 3.8, 3.9, 3.10 or 3.11

PAAS Accounts

Setting up each of these accounts will created credentials that must be entered into the pi_portal configuration file.

Slack

See this guide for setting up a bot on Slack.

AWS Infrastructure

You’ll need to create two S3 buckets:

  • one to archive logs

  • one to archive motion detection videos

It’s important to make sure these archival buckets are not publicly accessible! This AWS document offers some guidance on how to achieve this.

Create a set AWS cli credentials with write permissions to both of these buckets.

Use the following template to design your write access policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllPutObjectActions",
      "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:PutObjectAcl", "s3:PutObjectVersionAcl"],
      "Resource": ["arn of a bucket1", "arn of a bucket2"]
    }
  ]
}

You can also configure lifecycle rules for these buckets to control data retention. This is useful for tasks such as purging data older than n number of days.

Logz.io Integration

This service has a generous free tier that will allow you to search your logs and create useful reports and graphs. You will need to know your account’s log token, (check the website on how to configure filebeat to find it.)

pi_portal ships with a binary for filebeat that has been compiled for each supported arm platform. This binary is responsible for streaming your logs to logz.io.

Creating a configuration file

Once you’ve setup your PaaS accounts, it’s time to get started rolling your own configuration file. Here’s some resources to help:

  1. First it’s handy to look at the sample config included in the repository.

  2. For more detail on what the options all do, there’s a JSON schema documented here that can help you make the most of your config.

  3. The actual JSON schema is here and is used to do programmatic validation of your configuration.

  4. The motion configuration can be a bit overwhelming. The existing values in the sample config should get you started. You can also check out the motion and individual camera configuration files for a bit more information.

Installing The PI Portal Software

There are 3 primary delivery mechanisms for pi_portal:

Please see the installation guide for further details.

Up and Running with Logs and Slack

Once correctly configured and installed, you should be streaming your logs to logz.io. Using this service you can create custom notifications and integrate with dozens of other remote services.

You will also be receiving notifications on the configured Slack channel whenever a door is opened or closed. The Slack bot will respond to commands typed into the channel:

  • try the command help to get started.