Skip to content

Instantly share code, notes, and snippets.

@spacecowb0y
Last active November 24, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacecowb0y/b7a4f0fbf5d4de8adc6dab9b51b5e3fe to your computer and use it in GitHub Desktop.
Save spacecowb0y/b7a4f0fbf5d4de8adc6dab9b51b5e3fe to your computer and use it in GitHub Desktop.
Phillips Hue <-> Uptimerobot RSS trigger
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);
});
}
});
{
"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