Git Product home page Git Product logo

office-status-indicator's Introduction

Office Status Indicator

Summary

This is a project to create a Google Calendar integrated status indicator for home office use, based on the original project from TheAlanNix. It has been modified to use a Pimoroni Rainbow HAT instead of a Unicorn HAT Mini because...well, I had one lying around.

Office Status Indicator

This project utilizes the following hardware:

Requirements

  • A Google Project with the Calendar API enabled
  • The json file from a Native App OAuth Client (not a Service Account Credential)

Optional

  • Docker installed on your Raspberry Pi

Setup

First, you'll need to create a Google Calendar API project. There's a good tutorial here. Download the credentials.json file for the OAuth Client - you'll need it to allow the application to access your Google calendar - and then either copy the file to your data/ directory, or mount the file to the container from the host.

Run as a system service

Install the required packages by running sudo pip install -r requirements.txt

Make sure everything works as expected by manually invoking the office_status_indicator.py script.

Once you've confirmed that the configuration is correct, configure the service:

sudo cp office-status.service /etc/systemd/system/
sudo systemctl enable office-status
sudo systemctl start office-status

Run as a container (Needs Fix)

This method does not currently work with this code as-is; will fix later.

On the Raspberry Pi, run the following command to download and run the container:

docker run -it \
           --name office-status \
           --privileged \
           --restart=always \
           --volume $(pwd)/data:/app/data \
           --volume $(pwd)/data/credentials.json:/app/data/credentials.json:ro \
           alannix/office-status:latest

This will prompt you to visit a URL to authorize the script to have access to your Google Calendar. Once you have gone through the authorization process, you'll receive an authorization code that you'll need to provide back to the application. The authorization code is stored within the container, so you can safely exit (Control + c) and the container will restart and continue to run.

Once the application is authorized, it will check your Google Calendar for events every minute, determine if you're in a meeting, then update the state of the status light accordingly.

Configuration

You can tweak the operation of the script by providing any of the following environment variables:

Name Description Type Default
OFFICE_STATUS_HOUR_START The hour of the day that the status light should activate. Integer 8
OFFICE_STATUS_HOUR_END The hour of the day that the status light should de-activate. Integer 18
OFFICE_STATUS_TZ The timezone that should be used to determine working hours. String "America/New_York"
OFFICE_STATUS_WARNING_MINUTES The number of minutes prior to the next meeting that the light should change to 'warning' status. Integer 10
OFFICE_STATUS_WEEK_START The integer representation of the day of the week to start the work week (Monday is 0 and Sunday is 6) Integer 0
OFFICE_STATUS_WEEK_END The integer representation of the day of the week to end the work week (Monday is 0 and Sunday is 6) Integer 4

TODO

  • Add steps for creating Native OAuth Client ID
  • Get container working with Rainbow HAT (library issue with python3-smbus)

office-status-indicator's People

Contributors

thealannix avatar snyk-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.