timmson / node-lgtv-api

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

XML Builder Error #13

Closed geniusjam closed 4 years ago

geniusjam commented 4 years ago

I face this error when i do tvApi.processCommand(tvApi.TV_CMD_CHANGE_CHANNEL, [89]).then(console.log, console.error) (and for many other commands) Querying data is fine.

Error: Invalid character in name
    at XMLStringifier.module.exports.XMLStringifier.assertLegalName (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLStringifier.js:213:15)
    at XMLStringifier.assertLegalName (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLStringifier.js:4:59)
    at XMLStringifier.module.exports.XMLStringifier.name (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLStringifier.js:29:19)
    at new XMLElement (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLElement.js:26:34)
    at XMLElement.module.exports.XMLNode.node (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLNode.js:304:15)
    at XMLElement.module.exports.XMLNode.element (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLNode.js:236:28)
    at XMLElement.module.exports.XMLNode.ele (D:\Projects\webos\node_modules\xmlbuilder\lib\XMLNode.js:531:19)
    at D:\Projects\webos\node_modules\xml2js\lib\builder.js:65:42
    at Builder.exports.Builder.Builder.buildObject (D:\Projects\webos\node_modules\xml2js\lib\builder.js:120:14)
    at D:\Projects\webos\node_modules\node-lgtv-api\api.js:96:30
timmson commented 4 years ago

@NCem, hi! Thank you for your request. But now i don't own this model of TV and cannot reproduce this issue:(

timmson commented 4 years ago

@NCem, clould you set

tvApi.setDebugMode(true)

and try again?

geniusjam commented 4 years ago

Okay it started to get a lot more weird. I can't replicate it anymore. I'm sure that the credentials are right Here is my code and the output:

const TvApi = require("node-lgtv-api");
const tvApi = new TvApi("192.168.1.104", "8080", "806905");
tvApi.setDebugMode(true);
tvApi.authenticate().then(() => {
    console.log("Connected!");
    //tvApi.queryData(tvApi.TV_INFO_CHANNEL_LIST).then(arr=>console.log("channel count:", arr.length), console.error);
    //tvApi.processCommand(tvApi.TV_CMD_CHANGE_CHANNEL, [89]).then(console.log, console.error)
}, console.error);
PS D:\Projects\webos> node .\lgtvapi.js
REQ:undefined
RESP:<?xml version="1.0" encoding="utf-8"?><envelope><ROAPError>400</ROAPError><ROAPErrorDetail>Bad Request</ROAPErrorDetail></envelope>
Error: Response code:400
    at getErrorMessage (D:\Projects\webos\node_modules\node-lgtv-api\app.js:8:18)
    at Request._callback (D:\Projects\webos\node_modules\node-lgtv-api\app.js:106:50)
    at Request.self.callback (D:\Projects\webos\node_modules\request\request.js:185:22)
    at Request.emit (events.js:210:5)
    at Request.<anonymous> (D:\Projects\webos\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:210:5)
    at IncomingMessage.<anonymous> (D:\Projects\webos\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:299:28)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1184:12)
timmson commented 4 years ago

It seems, invalid otp is. Could you request new one?

new TvApi("192.168.1.104", "8080"); tvApi.setDebugMode(true); tvApi.authenticate().catch(err => console.log(err));

If all will be right, you ll see new code on your TV.