Skip to content

Instantly share code, notes, and snippets.

@kakopappa
Last active July 16, 2020 18:39
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 kakopappa/d531caeb2f755256c4e3050056723f6f to your computer and use it in GitHub Desktop.
Save kakopappa/d531caeb2f755256c4e3050056723f6f to your computer and use it in GitHub Desktop.
nodejs sinricpro example
const { SinricPro, SinricProActions, raiseEvent, eventNames, SinricProUdp } = require('sinricpro'); // Use require('sinricpro'); if you are using NPM
const appKey = ''; // d89f1***-****-****-****-************
const secretKey = ''; // f44d1d31-1c19-****-****-9bc96c34b5bb-d19f42dd-****-****-****-************
const device1 = ''; // 5d7e7d96069e275ea9******
const device2 = ''; // 5d80ac5713fa175e99******
const deviceId = [device1]
function setPowerState(deviceid, data) {
  console.log(deviceid, data);
  return true;
}
function setThermostatMode(deviceid, data) {
    console.log(deviceid, data);
    return true;
}
const callbacks = {
  setPowerState,
  setThermostatMode,
};
const sinricpro = new SinricPro(appKey, deviceId, secretKey, true);
SinricProActions(sinricpro, callbacks);
// const udp = new SinricProUdp(deviceId, secretKey);
// udp.begin(callbacks);
setInterval(() => {
  raiseEvent(sinricpro, eventNames.currentTemperature, device1, {
    "humidity": 75.3,
    "temperature": 24
} );
}, 10000); // 10 secs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment