Giter VIP home page Giter VIP logo

thingm-blink-api's Introduction

ThingM Blink(1) API

A simple Rest API for the ThingM Blink1 Device that allows for network control using Python, Flask, and Docker.

In this project, I use the existing python library for the ThingM blink1 to create a flask API, so that I can control the blink1 device over the network.

This will only work if you have a ThingM device connected to your PC. It is intended to be run in a docker container.

Requirements

You will need a ThingM Blink1 light device plugged into the system you are running the API on.

The API requires docker and docker-compose.

Setup

Getting the Files

Ensure git is installed, then clone the git repo.

git clone https://github.com/ethmth/thingm-blink-api.git
cd thingm-blink-api/

Configuration

The API is set to run on port 5000 in a docker container named blink-api. If you would like to change either of these values, edit the .env file.

Running the API

While in the repo directory, run the API using docker compose.

docker-compose up

Alternatively, you can set the API to run in the background.

docker-compose up -d

Stop the background container by entering the repo directory and running docker-compose stop

Allow docker some time to create the image and start the container before testing.

Usage

/fade

To turn the blink device on, use the /fade endpoint with the color and time query components. color can be a simple, plain-text color, a hexadecimal value, or RGB values separated by commas. time is the milliseconds it takes to change to that color completely from its existing state.

Example usages:

curl 'localhost:5000/fade?color=red&time=1500'
curl 'localhost:5000/fade?color=212,78,65'
curl 'localhost:5000/fade?color=#da4354&time=10'

/blink

The /blink endpoint also takes color and time query components. color follows the same rules as before, but now time is the milliseconds it takes to continuously alternate between the color specified and no light. This achieves a blinking effect.

Example usages:

curl 'localhost:5000/blink?color=blue'
curl 'localhost:5000/blink?color=#abab64&time=101'
curl 'localhost:5000/blink?color=45,232,12&time=2500'

/off

The /off endpoint takes no query parameters and simply sets the blink device to emit no light.

Example usage:

curl 'localhost:5000/off'

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.