An open API service indexing awesome lists of open source software.

https://github.com/carlgo11/nanoleaf-github-activity

GitHub Activity graph on Nanoleaf
https://github.com/carlgo11/nanoleaf-github-activity

activity-graph github-activity nanoleaf nanoleaf-canvas

Last synced: 7 months ago
JSON representation

GitHub Activity graph on Nanoleaf

Awesome Lists containing this project

README

          

# Nanoleaf Github Activity

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

## Installation

[![](https://img.shields.io/docker/image-size/carlgo11/nanoleaf-github-activity?label=Docker&logo=Docker&sort=semver&style=for-the-badge)](https://hub.docker.com/r/carlgo11/nanoleaf-github-activity)
[![](https://img.shields.io/docker/image-size/carlgo11/nanoleaf-github-activity?color=3fb930&label=GitHub&logo=GitHub&sort=semver&style=for-the-badge)](https://github.com/Carlgo11/nanoleaf-github-activity/pkgs/container/nanoleaf-github-activity)

### 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) | |

### 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.
```shell
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.

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

### Docker Compose

```yaml
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](https://support.apple.com/guide/shortcuts/welcome/ios), [Node-RED](https://nodered.org/), [Home Assistant](https://home-assistant.io).

## 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:

```json
{
"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:

```diff
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](https://res.cloudinary.com/dbsfyc1ry/image/upload/v1713221809/nanoleaf/02_14_cgtoso.svg)

### Halloween _(October 31st)_

![Halloween](https://res.cloudinary.com/dbsfyc1ry/image/upload/v1713221810/nanoleaf/10_31_afarls.svg)

### Christmas _(December 24th - 25th)_

![Christmas](https://res.cloudinary.com/dbsfyc1ry/image/upload/v1713221810/nanoleaf/12_25_q18913.svg)

## License

The project is licensed under GPLv3. See the full license in [LICENSE.md](LICENSE.md).