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 21 forks source link

Persistent connection and Tokens #42

Closed gdr2404 closed 3 years ago

gdr2404 commented 3 years ago

Every day i have to go into the lg control node and press connect, update and redeploy on the token. Is there a simple way I can point this to my token which seems to always stay the same?

Looking at closed issues i found this link and user who seems to have figured out how to do it, has anyone else managed this and can help shed some more light on how to do it?

Thanks

https://github.com/hobbyquaker/node-red-contrib-lgtv/issues/16

@nonkronk

Problem solved! I turned the log level to debug mode, Apparently, we have to provide a key on credentialSecret property in settings.js to encrypt our credentials with the chosen key. (i've never check the log before)

credentialSecret: "random-string"

By default Node-RED generates a random key for the encryption.

nodoubtman commented 3 years ago

oh gosh thank you so much!!! :)

gdr2404 commented 3 years ago

oh gosh thank you so much!!! :)

Did you figure it out? Can you shed any light on how you did it?

nodoubtman commented 3 years ago

@nonkronk solved it 👍

Problem solved!
I turned the log level to debug mode,
Apparently, we have to provide a key on credentialSecret property in settings.js to encrypt our credentials with the chosen key. (i've never check the log before)

credentialSecret: "random-string"

By default Node-RED generates a random key for the encryption.
gdr2404 commented 3 years ago

Yeah i posted that futher up from Nonkronk. Still a bit clueless as in how to do it. The log level part, where is this located?

Thanks

nodoubtman commented 3 years ago

Ok. You need to to go your node-red directory, ,

/home/pi/n/lib/node_modules/node-red

and locate the line: credentialSecret:

and you write "random-string"

after that.

Let me know how it goes. It works perfectly on my tv. Good luck. Marc.

nodoubtman commented 3 years ago

@gdr2404 Did it work ?

gdr2404 commented 3 years ago

Hi, sorry for my delay in getting back. Unfortunately i couldn't get it to work, definitely my lack of knowledge with this is the problem. I dont have the same file structure (pi4), so I can get as far as

/node_red/node_modules

but after this there's loads of folders. If its settings.js I should be amending I found that at

/config/node-red/settings.js

Inside this I found credentialsecret:

/**

So i'm at a bit of a loss with what to do or try.

nodoubtman commented 3 years ago

Hi, sorry for my delay in getting back. Unfortunately i couldn't get it to work, definitely my lack of knowledge with this is the problem. I dont have the same file structure (pi4), so I can get as far as

/node_red/node_modules

but after this there's loads of folders. If its settings.js I should be amending I found that at

/config/node-red/settings.js

Inside this I found credentialsecret:

/**

* PLEASE NOTE! IMPORTANT! READ!

* This is a modified version of the settings file. Some parts of the

* settings are actually controlled by the Home Assistant add-on.

* Parts that are handled by it, are removed from this settings template.

* The following configuration keys are controlled by the add-on and removed.

* * flowFile (fixed to flows.json)

* * credentialSecret (credentials_secret in the add-on configuration)

So i'm at a bit of a loss with what to do or try.

Find the line: credentialSecret: and after the : your write: "random-string"

credentialSecret: "random-string"

and reboot your raspberry pi 4 :)

Good luck.

Marc.

gdr2404 commented 3 years ago

Thanks Marc, definitely a step closer now with your help. I was defiantly over thinking this. If anyone else comes across this post the answer to my problem wasn't to go into the file editor and look for script.js.

In Home assistant just go into supervisor, then to your node red add-on. Once inside there go to the configuration tab where you probably typed your node red user and password whne you first downloaded the add-on. Then type in

credential_secret: random-string

Now whenever you restart your home assistant or turn off your tv, it should automatically connect. Now only if my tv auto connected, haha

nodoubtman commented 3 years ago

Glad it helps :) Marc.