Skip to content

Carlgo11/nanoleaf-github-activity

Repository files navigation

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.