Last active
November 24, 2017 14:43
-
-
Save spacecowb0y/b7a4f0fbf5d4de8adc6dab9b51b5e3fe to your computer and use it in GitHub Desktop.
Phillips Hue <-> Uptimerobot RSS trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let UPTIMEROBOT_RSS; | |
let HUE_HOST; | |
let HUE_USER; | |
let HUE_LIGHT_ID; | |
let huejay = require('huejay'); | |
let parser = require('rssparser'); | |
let client = new huejay.Client({ | |
host: HUE_HOST, | |
username: HUE_USER | |
}); | |
parser.parseURL(UPTIMEROBOT_RSS, (err, out) => { | |
if (out.items[0].title.includes(`is DOWN`)) { | |
client.lights.getById(HUE_LIGHT_ID) | |
.then(light => { | |
light.on = true; | |
light.hue = 65535; | |
light.saturation = 254; | |
light.alert = 'lselect'; | |
return client.lights.save(light); | |
}) | |
.then(light => { | |
console.log(`Alert on ${light.name}! ${out.items[0].title}!`); | |
}) | |
.catch(error => { | |
console.log('Something went wrong'); | |
console.log(error.stack); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "phillips-hue-uptimerobot-alert", | |
"version": "0.0.1", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"huejay": "^1.7.0", | |
"rssparser": "^0.0.10" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment