hobbyquaker / node-red-contrib-lgtv

Node-RED Nodes to control LG webOS Smart TVs :tv:
http://flows.nodered.org/node/node-red-contrib-lgtv
MIT License
59 stars 22 forks source link

TypeError: Cannot read property 'indexOf' of undefined #36

Open lavirott opened 3 years ago

lavirott commented 3 years ago

Hello, I would like to control my new LG TV with your node-red nodes which looks like interesting. Unfortunatly, I face an issue. I uploaded the remote control sample you provide. I configured the configuration node with the right IP address, connect and get the token. (I would like to add I can do some basic control of my LG TV with OpenHab, so this is not an issue of misconfiguration on the TV, it accepts remote control). My TV is: LG 49 NANO81

When deploying, I have the follwing error:

6 Dec 18:48:19 - [error] [function:app icon] TypeError: Cannot read property 'com.webos.app.hdmi4' of undefined
6 Dec 18:48:19 - [red] Uncaught Exception:
6 Dec 18:48:19 - TypeError: Cannot read property 'indexOf' of undefined
    at Object.83d1b8db.e8e0b8 (C:\Users\lavirott\.node-red\node_modules\node-red-contrib-lgtv\nodes\lgtv-mute.js:18:59)
    at C:\Users\lavirott\.node-red\node_modules\node-red-contrib-lgtv\nodes\lgtv-config.js:72:43
    at Array.forEach (<anonymous>)
    at LgtvConfigNode.subscriptionHandler (C:\Users\lavirott\.node-red\node_modules\node-red-contrib-lgtv\nodes\lgtv-config.js:71:49)
    at Object.9bf6b1c00002 (C:\Users\lavirott\.node-red\node_modules\node-red-contrib-lgtv\nodes\lgtv-config.js:38:26)
    at WebSocketConnection.<anonymous> (C:\Users\lavirott\.node-red\node_modules\lgtv2\index.js:149:48)
    at WebSocketConnection.emit (events.js:315:20)
    at WebSocketConnection.processFrame (C:\Users\lavirott\.node-red\node_modules\websocket\lib\WebSocketConnection.js:554:26)
    at C:\Users\lavirott\.node-red\node_modules\websocket\lib\WebSocketConnection.js:323:40
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

Thanks in advance for any help you for your promising nodes.

rysiok commented 3 years ago

I have the same error when trying to access my LG CX

nodoubtman commented 3 years ago

I have the same error when trying to access my LG CX

same here!

ZeroBLYNK commented 3 years ago

1 Feb 21:35:45 - [red] Uncaught Exception: 1 Feb 21:35:45 - TypeError: Cannot read property 'indexOf' of undefined at Object.98d0d50a.605e88 (/home/pi/.node-red/node_modules/node-red-contrib-lgtv/nodes/lgtv-volume.js:19:59) at /home/pi/.node-red/node_modules/node-red-contrib-lgtv/nodes/lgtv-config.js:72:43 at Array.forEach () at LgtvConfigNode.subscriptionHandler (/home/pi/.node-red/node_modules/node-red-contrib-lgtv/nodes/lgtv-config.js:71:49) at Object.a49fe3ac0002 (/home/pi/.node-red/node_modules/node-red-contrib-lgtv/nodes/lgtv-config.js:38:26) at WebSocketConnection. (/home/pi/.node-red/node_modules/lgtv2/index.js:149:48) at WebSocketConnection.emit (events.js:314:20) at WebSocketConnection.processFrame (/home/pi/.node-red/node_modules/websocket/lib/WebSocketConnection.js:554:26) at /home/pi/.node-red/node_modules/websocket/lib/WebSocketConnection.js:323:40 at processTicksAndRejections (internal/process/task_queues.js:79:11) at runNextTicks (internal/process/task_queues.js:66:3) at processImmediate (internal/timers.js:434:9) nodered.service: Main process exited, code=exited, status=1/FAILURE

musilex commented 2 years ago

Has anyone found a solution? I’m having the same problem.

nodoubtman commented 2 years ago

Yes, you can fix it yourself, see: edit : index.js

see the line:

// scan incoming messages for the magic string server.on('message', function(message, remote) {

if (message.indexOf("LG Smart TV"))) {

replace with:

if (message.indexOf("LG Smart TV") > 0) {

thats all :)

:)

musilex commented 2 years ago

This is in .node-red\node_modules\lgtv2\index.js? I don't see that line there.

Yes, you can fix it yourself, see: edit : index.js

see the line:

// scan incoming messages for the magic string server.on('message', function(message, remote) {

if (message.indexOf("LG Smart TV"))) {

replace with:

if (message.indexOf("LG Smart TV") > 0) {

thats all :)

:)

colinl commented 2 years ago

It seems that the correct fix for this is in .node-red/node_modules/node-red-contrib-lgtv/nodes/lgtv-volume.js at line 19, currently

                    if (!err && res && res && res.changed.indexOf('volume') !== -1) {
                        node.send({payload: res.volume});
                    }

should be

                    if (!err && res && res.changed && res.changed.indexOf('volume') !== -1) {
                        node.send({payload: res.volume});
                    }

Ref: https://discourse.nodered.org/t/node-red-keeps-rebooting-itself/56590/9