-
-
Save edgarsilva/3f9312f1e7b438869976 to your computer and use it in GitHub Desktop.
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
var cylon = require('cylon'); | |
cylon.api({ host: '0.0.0.0', port: '8080' }); | |
cylon.robot({ | |
connections: [ | |
{ name: 'hue', adaptor: 'hue', host: '192.168.1.64', username: '1234567890f' }, | |
{ | |
name: 'sfcon', | |
adaptor: 'force', | |
sfuser: 'YY', | |
sfpass: 'XX', | |
orgCreds: { | |
clientId: '3MVG9CVKiXR7Ri5ph7vqYjcek68_WRdVBAAmr91oLd2Upqr4YxxstOq1h07s8hqVlaa3K280.Lna5VsTyNRT0', | |
clientSecret: '4925856990747985903', | |
redirectUri: 'http://localhost:3000/oauth/_callback' | |
} | |
} | |
], | |
devices: [ | |
{name: 'bulb', driver: 'hue-light', lightId: 2, connection: 'hue'}, | |
{name: 'salesforce', driver: 'force', connection: 'sfcon'} | |
], | |
randomNumber: function() { | |
return Math.floor(Math.random() * 255); | |
}, | |
work: function(my) { | |
cylon.Logger.info("Starting SF Receiver"); | |
my.salesforce.subscribe('/topic/HueMsgOutbound', function(err, 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('Salesforce err:', err); | |
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