sinricpro / nodejs-sdk

Nodejs library for https://sinric.pro
11 stars 7 forks source link

Unexpected token ? in contorllers/tv_controller.js:58 #19

Closed drewklein20 closed 2 years ago

drewklein20 commented 2 years ago

`/home/pi/alexa/node_modules/sinricpro/lib/contorllers/tv_controller.js:58 const channel = payload.value.channel.name ?? payload.value.channel.number; ^

SyntaxError: Unexpected token ? at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/pi/alexa/node_modules/sinricpro/lib/cbhandler.js:15:40) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)`

kakopappa commented 2 years ago

Hi @drewklein20

I have tested the below basic switch sketch and seems to work without a problem.

Can you provide more details? example code perhaps

` 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 = ""; const deviceId = [device1];

function setPowerState(deviceid, data) { console.log(deviceid, data); return true; }

const callbacks = { setPowerState };

const sinricpro = new SinricPro(appKey, deviceId, secretKey, true);

SinricProActions(sinricpro, callbacks);

setInterval(() => { raiseEvent(sinricpro, eventNames.powerState, device1, { state: "On" }); }, 2000); `

image

drewklein20 commented 2 years ago

Sure thing. Here is my code, also I'm running node v10.24.0 (appKey, secretKey, and device were replaced with XXX)

`const { SinricPro, SinricProActions, raiseEvent, eventNames, SinricProUdp } = require("sinricpro"); // Use require('sinricpro'); if you are using NPM

const appKey = "XXX"; const secretKey = "XXX"; const device1 = "XXX"; const device2 = ""; const deviceId = [device1];

function setPowerState(deviceid, data) { console.log(deviceid, data); return true; }

const callbacks = { setPowerState };

const sinricpro = new SinricPro(appKey, deviceId, secretKey, true);

SinricProActions(sinricpro, callbacks);

setInterval(() => { raiseEvent(sinricpro, eventNames.powerState, device1, { state: "On" }); }, 2000);

// https://github.com/sinricpro/nodejs-sdk/blob/master/examples/simple-example/simple-example.js`

kakopappa commented 2 years ago

Likely ?? not supported in your nodejs version. I am on v14

On Fri, 12 Nov 2021 at 9:49 PM drewklein20 @.***> wrote:

Sure thing. Here is my code, also I'm running node v10.24.0 `const { SinricPro, SinricProActions, raiseEvent, eventNames, SinricProUdp } = require("sinricpro"); // Use require('sinricpro'); if you are using NPM

const appKey = "XXX"; const secretKey = "XXX"; const device1 = "XXX"; const device2 = ""; const deviceId = [device1];

function setPowerState(deviceid, data) { console.log(deviceid, data); return true; }

const callbacks = { setPowerState };

const sinricpro = new SinricPro(appKey, deviceId, secretKey, true);

SinricProActions(sinricpro, callbacks);

setInterval(() => { raiseEvent(sinricpro, eventNames.powerState, device1, { state: "On" }); }, 2000);

// https://github.com/sinricpro/nodejs-sdk/blob/master/examples/simple-example/simple-example.js`

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/sinricpro/nodejs-sdk/issues/19#issuecomment-967174099, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZXXIT4WRFPYWOXTPC3ULUSQZANCNFSM5HV42CRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

drewklein20 commented 2 years ago

Updating now!

drewklein20 commented 2 years ago

Thanks @kakopappa, looks like updating node worked. Currently on v16.13.0 and it's working great. @kakopappa maybe a good idea to add minimum node version supported with this package.