Skip to content

Instantly share code, notes, and snippets.

@radnip
Created October 21, 2014 19:00
Show Gist options
  • Save radnip/2abf7b41f93254e48b9e to your computer and use it in GitHub Desktop.
Save radnip/2abf7b41f93254e48b9e to your computer and use it in GitHub Desktop.
Cylon Hue test code
var Cylon = require('cylon');
Cylon.api({ host: '0.0.0.0', port: '8080' });
Cylon.robot({
connection: { name: 'hue', adaptor: 'hue', host: '192.168.1.64', username: '1234567890f' },
connection: { name: 'sfcon',
adaptor: 'force',
sfuser: 'YY',
sfpass: 'XX',
orgCreds: {
clientId: '3MVG9CVKiXR7Ri5ph7vqYjcek68_WRdVBAAmr91oLd2Upqr4YxxstOq1h07s8hqVlaa3K280.Lna5VsTyNRT0',
clientSecret: '4925856990747985903',
redirectUri: 'http://localhost:3000/oauth/_callback'
}
},
device: {name: 'bulb', driver: 'hue-light', lightId: 2},
device: {name: 'salesforce', driver: 'force'},
randomNumber: function() {
return Math.floor(Math.random() * 255);
},
work: function(my) {
Cylon.Logger.info("Starting SF Receiver");
my.salesforce.subscribe('/topic/HueMsgOutbound', function(data) {
Cylon.Logger.info("SF Msg Recieved");
var name = data.sobject.Name,
lamp_Id = data.sobject.Hue_Lamp_Id__c,
RGB_Red = data.sobject.Hue_RGB_Red__c,
RGB_Green = data.sobject.Hue_RGB_Green__c,
RGB_Blue = data.sobject.Hue_RGB_Blue__c,
state = data.sobject.Hue_State__c;
Cylon.Logger.info("Hue Lamp: #{ lamp_Id }, Action: #{ state }, RGB: #{ RGB_Red },#{ RGB_Green },#{ RGB_Blue }, ");
my.bulb.turnOn();
my.bulb.rgb(RGB_Red,RGB_Green,RGB_Blue);
/* every((1).second(), function() {
my.bulb.alert();
});
*/
});
}
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment