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

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

Open
lavirott opened this issue Dec 6, 2020 · 7 comments
Open

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

lavirott opened this issue Dec 6, 2020 · 7 comments

Comments

@lavirott
Copy link

lavirott commented Dec 6, 2020

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

rysiok commented Dec 8, 2020

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

@nodoubtman
Copy link

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

same here!

@ZeroBLYNK
Copy link

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

musilex commented Oct 5, 2021

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

@nodoubtman
Copy link

nodoubtman commented Oct 12, 2021

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

musilex commented Oct 18, 2021

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

colinl commented Jan 23, 2022

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

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

6 participants