Last active
July 16, 2020 18:39
-
-
Save kakopappa/d531caeb2f755256c4e3050056723f6f to your computer and use it in GitHub Desktop.
nodejs sinricpro example
This file contains hidden or 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
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