Skip to content

Commit

Permalink
Enhancements 001 (#3)
Browse files Browse the repository at this point in the history
* Crashed on missing token

* Enabled Repeat Commands w/ Delays

* SmartThings Integration Example

* Updated Dependencies

* Variable Device Type
  • Loading branch information
401Unauthorized authored Sep 2, 2020
1 parent 95bb55d commit 86034ee
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 345 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">BroadLink Bridge</h1>
<h3 align="center">An HTTP REST Bridge for Interacting with BroadLink IR Devices</h3>
<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<img alt="Version" src="https://img.shields.io/badge/version-1.1.0-blue.svg?cacheSeconds=2592000" />
<img src="https://img.shields.io/badge/node-%3E%3D8.17.0-blue.svg" />
<a href="https://github.com/401unauthorized/broadlink-bridge#readme" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
Expand Down Expand Up @@ -51,8 +51,8 @@ Run the CLI command to start the server:
- Use a GET/POST request without headers or a body to trigger IR commands (you know, to bookmark a URL to quickly turn on the TV)
- Multiple authentication options (bearer token and query string token)
- JSON formatted database file powered by [Lowdb](https://github.com/typicode/lowdb/blob/master/README.md) and [Lodash](https://lodash.com) enabling effortless modification, backup and sharing opportunities
- An accompanying [SmartThings](https://docs.smartthings.com/en/latest/device-type-developers-guide/quick-start.html) Device Handler example (Well, It's Coming Soon...)
- And a free "quick start" Postman Collection and example database!
- An accompanying [SmartThings](https://docs.smartthings.com/en/latest/device-type-developers-guide/quick-start.html) sample [Device Handler](https://github.com/401unauthorized/broadlink-bridge/blob/master/resources/smartthings_device_handler.groovy)
- And a free "quick start" [Postman Collection](https://github.com/401unauthorized/broadlink-bridge/blob/master/config) and example database!

## 👓 Transparency

Expand Down Expand Up @@ -202,7 +202,7 @@ A BroadLink IR Blaster
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand All @@ -215,7 +215,7 @@ A BroadLink IR Blaster

**name:** A user entered blaster name

**type:** A user entered blaster type (not used)
**type:** A user entered [blaster identifier](https://github.com/401Unauthorized/broadlinkjs-rm/blob/master/index.js#L8)

**address:** LAN IP address for the blaster

Expand Down Expand Up @@ -277,7 +277,7 @@ IR Codes & Metadata
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand Down Expand Up @@ -350,7 +350,7 @@ IR Codes & Metadata
```JSON
{
"version": "1.0.0"
"version": "1.1.0"
}
```

Expand Down Expand Up @@ -397,7 +397,7 @@ Read all Blasters
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand All @@ -409,14 +409,20 @@ Read all Blasters

#### POST /blasters/

Create a new Blaster
Create a new Blaster.

Blaster *type* can be derived through the following:
1. Check this list of [blaster identifiers](https://github.com/401Unauthorized/broadlinkjs-rm/blob/master/index.js#L8) and find the name of your product
2. Copy what is inside of the `[]` for the line with your product name
3. Run `node -e 'console.log(<paste-here>)'`
4. The resulting number is what to put for the `type` field in the JSON body

> Request (Body)
```JSON
{
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF"
Expand All @@ -429,7 +435,7 @@ Create a new Blaster
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand All @@ -452,7 +458,7 @@ Read a specific Blaster
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand All @@ -479,7 +485,7 @@ Update a specific Blaster
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster Updated",
"type": "RM Mini3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Test Blaster\",\n \"type\": \"RM 3\",\n \"address\": \"192.168.1.2\",\n \"port\": 80,\n \"mac\": \"AA:BB:CC:DD:EE:FF\"\n}",
"raw": "{\n \"name\": \"Test Blaster\",\n \"type\": \"148340\",\n \"address\": \"192.168.1.2\",\n \"port\": 80,\n \"mac\": \"AA:BB:CC:DD:EE:FF\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Test Blaster\",\n \"type\": \"RM 3\",\n \"address\": \"192.168.1.2\",\n \"port\": 80,\n \"mac\": \"AA:BB:CC:DD:EE:FF\"\n}",
"raw": "{\n \"name\": \"Test Blaster\",\n \"type\": \"148340\",\n \"address\": \"192.168.1.2\",\n \"port\": 80,\n \"mac\": \"AA:BB:CC:DD:EE:FF\"\n}",
"options": {
"raw": {
"language": "json"
Expand Down
2 changes: 1 addition & 1 deletion express/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const corsSettings = {
};

module.exports.middleware = function (app, express) {
morgan.token('apikey', (req, res) => req.user.token);
morgan.token('apikey', (req, res) => req.user && (req.user.token));
app.use(morgan(':date[iso] :method :url :status :response-time ms :user-agent token=:apikey'));
app.use(cors(corsSettings));
app.use(express.json());
Expand Down
16 changes: 8 additions & 8 deletions models/lowdb/db-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "RM3",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
Expand All @@ -19,13 +19,13 @@
"type": "PROJECTOR",
"commands": [
{
"command": "power on",
"command": "power_on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
{
"command": "power off",
"command": "power_off",
"repeat": 1,
"delay": 300,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
Expand Down Expand Up @@ -73,7 +73,7 @@
"data": "260050000001289514121412141214131412141214121338133814381338133813381438133813131338131314381313141214121412131313131338141314371338133814381437140005110001284a13000d050000000000000000"
},
{
"command": "volume down",
"command": "volume_down",
"repeat": 0,
"delay": 0,
"data": "2600500000012895141214121313141214121412141215371437133813381339133814371437141214381412141214371412141214121412141214371339131314371338133813381500050f0001284a13000d050000000000000000"
Expand All @@ -85,7 +85,7 @@
"data": "260050000001289515121412141213131412131314121437133814381437133814371438133813131437131315111438141213131338141214121437143715121338133814121437140005100001294914000d050000000000000000"
},
{
"command": "volume up",
"command": "volume_up",
"repeat": 0,
"delay": 0,
"data": "260050000001279614121412141214121412141214121437133913381437133815371437143714121438131314371313143713131412151115121338141214371412133814381437130005110001284a14000d050000000000000000"
Expand All @@ -97,13 +97,13 @@
"data": "260050000001289514121412141214121412141213131437143813381437133913381338143714121412151214371437141214121437131315371338141214121437133814131437130005110001284914000d050000000000000000"
},
{
"command": "scroll up",
"command": "scroll_up",
"repeat": 0,
"delay": 0,
"data": "2600500000012895141214121412141214121412141214371537133813381437143715371338131314371437141215121437141213131412141213131437133815121437133814371400050f0001294a13000d050000000000000000"
},
{
"command": "keystone top",
"command": "keystone_top",
"repeat": 0,
"delay": 0,
"data": "26005400090001db00012895141215121313141214121412141214371338133913381338143714381437131314121412143713131437141314121412143714371313143714121438143714371500050e0001284a14000d0500000000"
Expand Down Expand Up @@ -139,7 +139,7 @@
"data": "2600500000012895141214121512141214121313141213381338133813391338133814371437151214371313141213131437131313131412141214371438143713131338143714381400050f0001284a13000d050000000000000000"
},
{
"command": "scroll down",
"command": "scroll_down",
"repeat": 0,
"delay": 0,
"data": "260050000001289514121412151214121412141213131437133813381537133814371437143814121412143713131412143715121412141213381313143713381412153714371338130005110001294913000d050000000000000000"
Expand Down
Loading

0 comments on commit 86034ee

Please sign in to comment.