blink1

Build Status version git github

Custom small and simple build of blink1-tool for the blink(1).

Overview

This builds blink1-tool and blink1-tiny-server and provides a .deb package with as a systemd units, udev rules.

Installation

The .deb packages are distributed on apt.sudo.is, which can be added in the standard way:

$ sudo curl https://apt.sudo.is/KEY.gpg -o /etc/apt/keyrings/apt.sudo.is.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/apt.sudo.is.gpg] https://apt.sudo.is /" | sudo tee -a /etc/apt/sources.list.d/apt.sudo.is.list
$ sudo apt update

Install the blink1 package:

$ sudo apt install blink1

Configuration

blink1-tiny-server

Configure which port it listens to in /etc/default/blink1-tiny-server:

BLINK1_TINY_SERVER_PORT=8011

nginx

To configure a Nginx reverse proxy on the path /blink1:

location /blink1/ {
    # For HTML page:
    #rewrite '^/blink1(/.*)$' $1 break;
    #sub_filter_once off;
    #sub_filter '"/' '"./';
    add_header Content-Type 'application/json' always;
    proxy_http_version 1.1;
    proxy_pass http://localhost:8011;
}

Home Assistant

For adding the blink(1) as a light entity in Home Assistant, see home-assistant/blink1.yaml.

Usage

HTTP API

There is a very simply HTTP API that can be used to control the blink(1) or get the current state:

$ curl -sX GET http://localhost:8011/blink1/fadeToRGB?rgb=ff0ff
$ curl -sX GET https://blink1-host.example.com/blink1/ | jq .
{
  "version": "v2.3.0-linux-x86_64",
  "uri": "/blink1/",
  "millis": 0,
  "time": 0,
  "rgb": "#ff0ff",
  "ledn": 0,
  "bright": 0,
  "count": 0,
  "status": "blink1 status"
}

systemd service

The package provices a standard systemd service for blink1-tiny-server:

$ sudo systemctl status blink1-tiny-server.service | cat
● blink1-tiny-server.service - blink(1) tiny http server
     Loaded: loaded (/lib/systemd/system/blink1-tiny-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-10-03 23:48:31 CEST; 1 week 1 day ago
   Main PID: 1644193 (blink1-tiny-ser)
      Tasks: 1 (limit: 8999)
     Memory: 24.0M
        CPU: 54.354s
     CGroup: /system.slice/blink1-tiny-server.service
             └─1644193 /usr/local/bin/blink1-tiny-server -p 8011

systemd[1]: Started blink(1) tiny http server.
blink1-tiny-server[1644193]: blink1-tiny-server version v2.3.0-linux-x86_64: running on http://localhost:8011/ (html help enabeld)

--help

The --help output from blink1-tiny-server is informative:

$ blink1-tiny-server --help
Usage:
  blink1-tiny-server [options]
where [options] can be:
  --port port, -p port           port to listen on (default 8934)
  --host host, -H host           host to listen on ('127.0.0.1' or '0.0.0.0')
  --no-html                      do not serve static HTML help
  --logging                      log accesses to stdout
  --version                      version of this program
  --help, -h                     this help page

Supported URIs:
  /blink1/ -- simple status page
  /blink1/id -- get blink1 serial number
  /blink1/on -- turn blink(1) full bright white
  /blink1/off -- turn blink(1) dark
  /blink1/red -- turn blink(1) solid red
  /blink1/green -- turn blink(1) solid green
  /blink1/blue -- turn blink(1) solid blue
  /blink1/cyan -- turn blink(1) solid cyan
  /blink1/yellow -- turn blink(1) solid yellow
  /blink1/magenta -- turn blink(1) solid magenta
  /blink1/fadeToRGB -- turn blink(1) specified RGB color by 'rgb' arg
  /blink1/blink -- blink the blink(1) the specified RGB color
  /blink1/pattern/play -- play color pattern specified by 'pattern' arg
  /blink1/random -- turn the blink(1) a random color
  /blink1/servertickle/on -- Enable servertickle, uses 'millis' or 'time' arg
  /blink1/servertickle/off -- Disable servertickle

Supported query arguments: (not all urls support all args)
  'rgb'    -- hex RGB color code. e.g. 'rgb=FF9900' or 'rgb=%23FF9900'
  'time'   -- time in seconds. e.g. 'time=0.5'
  'bright' -- brightness, 1-255, 0=full e.g. half-bright 'bright=127'
  'ledn'   -- which LED to set. 0=all/1=top/2=bot, e.g. 'ledn=0'
  'millis' -- milliseconds to fade, or blink, e.g. 'millis=500'
  'count'  -- number of times to blink, for /blink1/blink, e.g. 'count=3'
  'pattern'-- color pattern string (e.g. '3,00ffff,0.2,0,000000,0.2,0')

Examples:
  /blink1/blue?bright=127 -- set blink1 blue, at half-intensity
  /blink1/fadeToRGB?rgb=FF00FF&millis=500 -- fade to purple over 500ms
  /blink1/pattern/play?pattern=3,00ffff,0.2,0,000000,0.2,0 -- blink cyan 3 times

References

1

todbot/blink1-tool - GitHub: the upstream repo that blink1-tool and blink1-tiny-server are built from.