Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
drewklein20 opened this issue Nov 9, 2021 · 5 comments
Closed

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

drewklein20 opened this issue Nov 9, 2021 · 5 comments

Comments

@drewklein20
Copy link

`/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
Copy link
Collaborator

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
Copy link
Author

drewklein20 commented Nov 12, 2021

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
Copy link
Collaborator

kakopappa commented Nov 12, 2021 via email

@drewklein20
Copy link
Author

Updating now!

@drewklein20
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants