timmson / node-lgtv-api

Node.js API for the remote control of LG SmartTV (2012+)
MIT License
26 stars 8 forks source link

Error: Invalid character in name #17

Open matjanfedev opened 4 years ago

matjanfedev commented 4 years ago

Hey I've an problem with this lines: function startTv(): void { const TvApi = require('node-lgtv-api'); const tvApi = new TvApi('192.168.1.192', '8080', '325887'); tvApi.setDebugMode(true); console.log(tvApi); tvApi.authenticate().then(() => { tvApi.processCommand(tvApi.TV_CMD_NUMBER_4, [], function (err, data) { if (err) { console.error(err); } else { console.log(data); } }); }); } Error: Unhandled Promise rejection: Invalid character in name ; Zone: <root> ; Task: Promise.then ; Value: Error: Invalid character in name at XMLStringifier../node_modules/xmlbuilder/lib/XMLStringifier.js.module.exports.XMLStringifier.assertLegalName (server/main.js:175469:15) at XMLStringifier.assertLegalName (server/main.js:175260:59) at XMLStringifier../node_modules/xmlbuilder/lib/XMLStringifier.js.module.exports.XMLStringifier.name server/main.js:175285:19) at new XMLElement (server/main.js:173730:34) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.node (server/main.js:174386:15) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.element (server/main.js:174318:28) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.ele (server/main.js:174613:19) at server/main.js:171031:42 at Builder../node_modules/xml2js/lib/builder.js.exports.Builder.Builder.buildObject (server/main.js:171086:14) at server/main.js:134003:39 Error: Invalid character in name at XMLStringifier../node_modules/xmlbuilder/lib/XMLStringifier.js.module.exports.XMLStringifier.assertLegalName (server/main.js:175469:15) at XMLStringifier.assertLegalName (server/main.js:175260:59) at XMLStringifier../node_modules/xmlbuilder/lib/XMLStringifier.js.module.exports.XMLStringifier.name (server/main.js:175285:19) at new XMLElement (server/main.js:173730:34) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.node (server/main.js:174386:15) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.element (server/main.js:174318:28) at XMLElement../node_modules/xmlbuilder/lib/XMLNode.js.module.exports.XMLNode.ele (server/main.js:174613:19) at server/main.js:171031:42 at Builder../node_modules/xml2js/lib/builder.js.exports.Builder.Builder.buildObject (server/main.js:171086:14) at server/main.js:134003:39

timmson commented 4 years ago

Hi, @matjanfedev

Could you post request and response? They should be printed to the console, if setDebug was true.

matjanfedev commented 4 years ago
Screenshot 2020-09-13 at 21 46 34
timmson commented 4 years ago

It seems something wrong at line 67. Try this tvApi.processCommand(tvApi.TV_CMD_MUTE_TOGGLE, []).then(resp => console.log (resp), err=>console.error(err));

matjanfedev commented 4 years ago

it doesnt matter. With then() is the same effect. The red line under ''function'' is a ts-lint issue (suggest to change into arrow function)

timmson commented 4 years ago

Declaration of function https://github.com/timmson/node-lgtv-api/blob/master/app.js#L56 says processCommand have only 2 parameters: commandName, parameters. Unfortunately, i dont have this model of TV anymore and have no chances to check it right now. However, req and resp are right, thats why you can suggest PR, if you would find the root of problem, thx!

mrazon87 commented 3 years ago

Hi everyone, did you find the solution for the "Error: Invalid character in name" issue? I have completely the same...

Many thanks!

timmson commented 2 years ago

Hi, @abossard, @matjanfedev, @kennyyuen

Could you test this version, plz? - https://www.npmjs.com/package/node-lgtv-api/v/0.9.8

TomHart commented 1 year ago

I'm having this issue with version 0.9.8 still

timmson commented 1 year ago

I'm having this issue with version 0.9.8 still

Hi! Could you debug and fix this issue? Then I can merge you PR.