Skip to content

Watch your pfSense® firewall temperature with blink(1) using Node.js® runtime

License

Notifications You must be signed in to change notification settings

amacado/pfsense-blink1

Repository files navigation

pfsense-blink(1)


blink(1) pfSense®

Introduction

Watch your pfSense® firewall temperature with blink(1) using Node.js® runtime

Quickstart

Docker (recommended: docker-compose.yml)

docker pull ghcr.io/amacado/pfsense-blink1:latest

Requirements

  • blink(1) mk2 or mk3 by THINGM
    mk1 does not have two LEDs on both top and bottom which are independently addressable. It might work, but not tested.

Preparations & setup

The intended deployment of this script is on another machine (or container) than the pfSense®. It's recommended to keep your firewall server as "clean" as possible.

  1. Setup jaredhendrickson13/pfsense-api for pfSense®
  2. Create an API Token for the REST API (see jaredhendrickson13/pfsense-api instructions)
  3. Install libusb driver apt-get install libusb-1.0-0 which is required to access the blink(1) device using the node package sandeepmistry/node-blink1
  4. Install nodejs (see nodejs.org)
  5. Connect the blink(1) via USB

Run the application

  1. Copy config/config.sample.json5, rename it to /path/to/config.json5 (default /config/config.json5) and paste API credentials and pfSense® URI (see json5.org for more information about the this next level json project)
  2. Adjust settings in config/config.json5 to your needs. The default values are defined in ConfigurationManager
  3. Install and startpfsense-blink1 application
    npm i pfsense-blink1 -g
    pfsense-blink1 [--config "/path/to/config.json5"]

Development or 'Go build yourself'

  1. Install yarn package manager (see yarnpkg.com)
  2. Clone this repository (gh repo clone amacado/pfsense-blink1)
  3. Execute yarn install
  4. Execute yarn serve for TypeScript watcher
  5. Execute yarn build to build the project and create production ready project in /dist/
  6. Setup pre-push hook with following script
    #!/bin/sh
    yarn build
    git add dist/
    git diff-index --quiet HEAD || git commit -m ":octocat: build sources via pre-push hook"
    
    exit 0

Publishing new (npm package) version

This project follows Semantic Versioning 2.0.0 with the help ofnp CLI tool to ensure quality.

yarn global add np
npm install np -g

Create a new version and publish (np is installed as dev-dependency):

np

Known problems

Error TypeError: cannot open device with path

This error may occurs when the current user is not allowed to access the attached blink(1) device:

TypeError: cannot open device with path /dev/hidraw0

If you're running this script in a docker container you might want to check the bindings and mount /dev:/dev which allows the container to access the device.

Error libusb-1.0.so.0: cannot open shared object file
Error: libusb-1.0.so.0: cannot open shared object file: No such file or directory

This error occurs if you haven't installed libusb driver apt-get install libusb-1.0-0.

ERR! self signed certificate
ERR! self signed certificate

This error occurs when the SSL certificate which should secure your REST API connection is self signed. There are two solutions for this problem: Either authorize your SSL certificate or skip the check by setting configuration option api.httpsAgent.rejectUnauthorized = false (see /config/config.sample.json5).

Credits

Special thanks to these projects:



forthebadge forthebadge forthebadge forthebadge