Skip to content

Commit

Permalink
Removes hue module and switches to axios (patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrrrzzt committed Jun 28, 2018
1 parent 99a504f commit 44614b7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 45 deletions.
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,46 @@ Pick your area from [this list](https://s3.eu-central-1.amazonaws.com/luftstatus

Add it to [config.json](config.json)

## Find bridgeip and add a user
## Find bridgeip

First run the setup script
First run find bridge script

```
$ npm run setup
$ npm run findBridge
```

This will result in an error. Now push the link-button on your bridge and rund the script again.
This will return a list of bridges on your network.

```JavaScript
[
{
"id": "0287dgdt93",
"internalipaddress": "192.168.1.110"
}
]
```
$ npm run setup

Add the ```internalipaddress``` value to your config's ```bridge```

## Add a user

Push the link button on your bridge and run the addUser script

```
$ npm run addUser
```

```JavaScript
[
{
"success": {
"username": "VK5h1bIbP6wtyAz6W4O5VbcuVqbrdqU4-iqLiyVU"
}
}
]
```

Add the values to [config.json](config.json) and move on.
Add the values from ``` username ``` to [config.json](config.json) and move on.

## Find your lightbulbs

Expand All @@ -55,7 +80,7 @@ Run the list script
$ npm run list
```

Find the light you want and add it to [config.json](config.json)
Find the light you want to use and add the id to [config.json](config.json)

You are now ready to start.

Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"bridge": "127.0.0.1",
"username": "c1faa0ab-11aa-466a-b87e-20aefbccfb8b",
"bridge": "192.168.10.153",
"username": "VK5h1bIbP6wtyAz6W4O5VbcuVqbrdqU4-iqLiyVU",
"light": 3,
"serviceUrl": "https://s3.eu-central-1.amazonaws.com/luftstatus/areas.json",
"area": "Grenland",
Expand Down
16 changes: 0 additions & 16 deletions lib/list-lights.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/setup.js

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"coverage": "nyc ava",
"coveralls": "nyc ava && nyc report --reporter=lcov && cat coverage/lcov.info | coveralls",
"standard-fix": "standard --fix",
"findBridge": "node utils/find-bridge",
"addUser": "node utils/add-user",
"list": "node utils/list-lights.js",
"start": "node index.js",
"setup": "node lib/setup.js",
"list": "node lib/list-lights.js",
"refresh": "rm -rf node_modules && rm package-lock.json && npm install"
},
"keywords": [
Expand All @@ -45,7 +46,6 @@
"standard": "11.0.1"
},
"dependencies": {
"axios": "0.18.0",
"philips-hue": "1.2.0"
"axios": "0.18.0"
}
}
13 changes: 13 additions & 0 deletions utils/add-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const axios = require('axios')
const config = require('../config.json')

async function addUser () {
// const buttonUrl = `http://${config.bridge}/api`
const userUrl = `http://${config.bridge}/api`
// const { data: button } = await axios.put(buttonUrl, {linkbutton: true})
// console.log(JSON.stringify(button, null, 2))
const { data: user } = await axios.post(userUrl, {devicetype: 'luftstatus'})
console.log(JSON.stringify(user, null, 2))
}

addUser()
6 changes: 6 additions & 0 deletions utils/find-bridge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const axios = require('axios')
const upnpUrl = 'http://www.meethue.com/api/nupnp'

axios(upnpUrl).then(result => {
console.log(JSON.stringify(result.data, null, 2))
}).catch(console.error)
7 changes: 7 additions & 0 deletions utils/list-lights.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const axios = require('axios')
const config = require('../config.json')
const url = `http://${config.bridge}/api/${config.username}/lights`

axios.get(url).then(result => {
console.log(JSON.stringify(result.data, null, 2))
}).catch(console.error)

0 comments on commit 44614b7

Please sign in to comment.