Coder Social home page Coder Social logo

carlgo11 / nanoleaf-github-activity Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 87 KB

GitHub Activity graph on Nanoleaf

License: GNU General Public License v3.0

Dockerfile 9.36% JavaScript 90.64%
nanoleaf nanoleaf-canvas github-activity activity-graph

nanoleaf-github-activity's Introduction

Nanoleaf Github Activity

GitHub Activity graph on Nanoleaf Canvas using the Nanoleaf LAN API.

Installation

Environment Variables

The project requires the following environment variables to be present.

Name Description Example
GITHUB_USER GitHub Username "Carlgo11"
NANOLEAF_HOST LAN IP and port of the Nanoleaf Canvas "192.168.1.2:16021"
NANOLEAF_TOKEN Nanoleaf Auth Token

Auth Token

Controlling the Nanoleaf lights requires an "auth token". Follow the instructions below to generate a token.

  1. Send a POST request from your computer to the Nanoleaf lights.
    curl -X "POST" http://192.168.1.2:16021/api/v1/new
  2. Press and hold the power button on the lights for 5-7 seconds.
  3. You should now have received a 32 character long "auth token" on your computer. Save this inside your .env as NANOLEAF_TOKEN

Note

Replace 192.168.1.2 with the IP address of your Nanoleaf lights. The default port is 16021.

Usage

The Node.js code is written to be run inside a Docker container. You can either use a Docker Compose file or just run a Docker command to start the container. Running this container will expose a Node.js server on port 3000. Any HTTP connections to this server trigger the code to fetch recent GitHub activities and update the Nanoleaf Canvas accordingly.

Note

Remember to first populate your .env-file with the required data.

Docker

Run the Docker container using the provided environment variables from the .env file.

docker run --env-file .env --ports 3000:3000 carlgo11/nanoleaf-github-activity

Docker Compose

version: '3.8'
services:
  nanoleaf:
    image: carlgo11/nanoleaf-github-activity
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "3000:3000"

Updating the lights

Once you've started the Docker container, you can access the Node.js server on http://localhost:3000. Every time you access this page, the nanoleaf lights will update. I recommend either setting up a cronjob on your server, or a home automation service such as Apple Shortcuts, Node-RED, Home Assistant.

Festive colors

During certain dates, the default colors change on the Canvas. Should you not want this, you can create a file called colors.json with the following data:

{
  "default": [
    "#EBEDF0",
    "#9BE9A8",
    "#40C463",
    "#30A14e",
    "#216E39"
  ]
}

The above-mentioned code will cause the Canvas to always use the same colors for the graph. To add it to your container, append your docker-compose.yml file with the following lines:

version: '3.8'
services:
  nanoleaf:
    image: carlgo11/nanoleaf-github-activity
    restart: unless-stopped
    env_file:
      - .env
    ports:
      - "3000:3000"
+    volumes:
+      - "./colors.json:/app/colors.json"

Here's a graphical demonstration of the custom festive colors

Valentines Day (February 14th)

Valentines Day

Halloween (October 31st)

Halloween

Christmas (December 24th - 25th)

Christmas

License

The project is licensed under GPLv3. See the full license in LICENSE.md.

nanoleaf-github-activity's People

Contributors

carlgo11 avatar

Watchers

 avatar  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.