LG WebOS better integration

Thanks for your answer, I’ll try these settings…!

1 Like

Sort of worked fine since day 1. Wired LAN.

Hm, I just realized WebOS is stilll SDK2 - @MaxvandeLaar , do you plan to upgrade your app please ? I see nobody asked yet ;-(

this week i recieved an answer that he is working on it now, but it is more work then it looks.

1 Like

Tested this for a few days, and unfortunately still not very reliable. The problem is when I turn of the TV, it directly sets the TV to off in Homey (so that’s great). But after a few seconds in Homey the TV is on again. And then after a few minutes the TV turns off again, this happens after the click you can hear from the TV when it’s really turning off (it looks like the TV uses a few minutes to cool down after you turn off the TV with the remote. So it’s really turned off after a few minutes)

Have you tried setting the Use polling instead of on/off listeren to Yes? After setting that to true, try to set the poll interval to 30 and the poll timeout to 20 for example. This means the App will check every 30s if the TV is on or off. If the TV is on it will know that immediately, in case it is off, it takes 20 seconds for the App to determine it is off. The timeout number should never be higher than the interval.

Just play around with those to numbers, the poll interval, and the poll timeout, until you found your personal sweet spot.

I’ll try that. What time between the interval and timeout would you recommend when i’m lowering the seconds? Always the 10 seconds, for example ending with interval 15 and timeout 5?

@MaxvandeLaar: using this app from today. Awesome on/off detection with my LG G1 tv.

Thank you! :slightly_smiling_face:

Since a few days, the app isn’t registering on/off or controlling any other function for my LG C2 anymore. Only recent change was an LG update for the TV. I’m now running 03.30.16. I haven’t recorded the exact timeline (we still use the remote mainly), so it might be something different.

I still have the Athom-version as well, and same behavior, also no response/feedback.

What I’ve done so far in an attempt to resolve:

  • Removed the device and tried to add a new device
    ** It does recognize the TV
    ** config displays the right IP-address
    ** any button responds with “not connected”
  • Stopped and restarted the app
  • Removed the app and reinstalled from the Community Store
    ** same as above
  • Removed the device from the Athom-version
    ** It recognizes the TV
    ** during install a confirmation is expected to display on the TV (which isn’t, resulting in a timeout)
  • Reset the TV to factory default
    ** Enabled BT and wifi connectivity, etc
  • Repeated steps above multiple times in different order, no change
  • TV is displayed in Fing (network discovery tool)
  • TV responds to a Wake-On-Lan request

Anything else I can try and fix? Anyone else running 03.30.16 with no issues?
I don’t see a button to send a diagnostic report from the community version.

Hmmm I see you already tried more than I would have suggested. I am currently working on rewriting the app from SDK2 to SDK3. I will add logs to the app so you can view those and send them to me in case of malfunction.

I know this doesn’t help you at the moment, sorry for that. I really don’t have a suggestion at this time beside pulling the app from GitHub and do a CLI run so you can see the logging in the terminal.

2 Likes

Hi. I have the exact same problem after the latest C2 update, and have done most of the things mentioned above. Keep up the good work, and hopefully we’ll have a fix soon :hugs:

Hi @MaxvandeLaar, I installed the app using the CLI:

\Projects\homey-webos-plus-master>homey app run
✓ Pre-processing app...
✓ Validating app...
Warning: flow.triggers['webos_channel_changed_to_number'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.triggers['webos_channel_changed_to_list'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.triggers['webos_app_changed_to'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.triggers['webos_sound_output_changed_to'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_sound_output'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_channel_number'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_channel_list'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_volume_equals'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_volume_smaller'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_volume_larger'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.conditions['webos_app'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['send_toast'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['send_toast_with_image'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['change_sound_output'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['change_channel_number'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['launch_app'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['change_channel_list'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['simulate_button'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
Warning: flow.actions['switch_input'].titleFormatted is missing. Specifying a Flow card's formatted title will be required in the future.
✓ App validated successfully against level `debug`
✓ Packing Homey App...
 — App archive size: 4.55 MB, 941 files
✓ Installing Homey App on `Homey` (http://192.168.###.###:80)...
✓ Homey App `com.maxvandelaar.webos-plus` successfully installed
✓ Running `com.maxvandelaar.webos-plus`, press CTRL+C to quit
 — Profile your app's performance at https://go.athom.com/app-profiling?homey=########################&app=com.maxvandelaar.webos-plus
─────────────── Logging stdout & stderr ───────────────
2023-02-01 13:54:13 [log] [WebosPlus] WebOS Plus is running...
2023-02-01 13:54:13 [log] [ManagerDrivers] [webos_plus] WebosPlus Driver has been inited
2023-02-01 13:54:38 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] onInit: Device Ready!
2023-02-01 13:54:38 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _connect: Connect to TV 192.168.###.###
2023-02-01 13:54:40 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at Socket.socketOnEnd (node:_http_client:466:23)
    at Socket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}
2023-02-01 13:54:46 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
2023-02-01 13:54:51 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at Socket.socketOnEnd (node:_http_client:466:23)
    at Socket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}
2023-02-01 13:54:54 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeUp: Called
2023-02-01 13:54:54 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeUp: Current volume null. Try to increase the volume
2023-02-01 13:54:54 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeUp: Send request to increase volume
2023-02-01 13:54:54 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/volumeUp
2023-02-01 13:54:54 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/volumeUp Error: not connected
    at LGTV.send (/drivers/webos_plus/lgtv2/lgtv2.js:196:12)
    at LGTV.request (/drivers/webos_plus/lgtv2/lgtv2.js:181:10)
    at /drivers/webos_plus/webos/WebOSTV.js:333:17
    at new Promise (<anonymous>)
    at WebosPlusDevice._volumeUp (/drivers/webos_plus/webos/WebOSTV.js:332:12)
    at WebosPlusDevice.volumeUp (/drivers/webos_plus/device.js:469:33)
    at WebosPlusDevice.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Device.js:1:1765)
    at WebosPlusDevice.emit (node:events:526:28)
    at WebosPlusDriver.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Driver.js:1:1919)
    at WebosPlusDriver.emit (node:events:526:28)
2023-02-01 13:54:54 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeUp: ssap://audio/volumeUp with result: undefined
2023-02-01 13:54:57 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeUp: Called
2023-02-01 13:54:57 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeUp: Current volume null. Try to increase the volume
2023-02-01 13:54:57 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeUp: Send request to increase volume
2023-02-01 13:54:57 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/volumeUp
2023-02-01 13:54:57 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/volumeUp Error: not connected
    at LGTV.send (/drivers/webos_plus/lgtv2/lgtv2.js:196:12)
    at LGTV.request (/drivers/webos_plus/lgtv2/lgtv2.js:181:10)
    at /drivers/webos_plus/webos/WebOSTV.js:333:17
    at new Promise (<anonymous>)
    at WebosPlusDevice._volumeUp (/drivers/webos_plus/webos/WebOSTV.js:332:12)
    at WebosPlusDevice.volumeUp (/drivers/webos_plus/device.js:469:33)
    at WebosPlusDevice.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Device.js:1:1765)
    at WebosPlusDevice.emit (node:events:526:28)
    at WebosPlusDriver.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Driver.js:1:1919)
    at WebosPlusDriver.emit (node:events:526:28)
2023-02-01 13:54:57 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeUp: ssap://audio/volumeUp with result: undefined
2023-02-01 13:55:00 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeMute: Called true
2023-02-01 13:55:00 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] volumeMute: Try to set mute to true
2023-02-01 13:55:00 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeMute: Send request to set mute to true
2023-02-01 13:55:00 [log] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/setMute
2023-02-01 13:55:00 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _handleResponse: ssap://audio/setMute Error: not connected
    at LGTV.send (/drivers/webos_plus/lgtv2/lgtv2.js:196:12)
    at LGTV.request (/drivers/webos_plus/lgtv2/lgtv2.js:181:10)
    at /drivers/webos_plus/webos/WebOSTV.js:313:17
    at new Promise (<anonymous>)
    at WebosPlusDevice._volumeMute (/drivers/webos_plus/webos/WebOSTV.js:312:12)
    at WebosPlusDevice.volumeMute (/drivers/webos_plus/device.js:453:33)
    at WebosPlusDevice.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Device.js:1:1765)
    at WebosPlusDevice.emit (node:events:526:28)
    at WebosPlusDriver.__onSetCapability (/opt/homey-client/system/manager/ManagerApps/AppProcess/node_modules/homey-apps-sdk-v2/lib/Driver.js:1:1919)
    at WebosPlusDriver.emit (node:events:526:28)
2023-02-01 13:55:00 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] _volumeMute: ssap://audio/setMute with result: undefined
2023-02-01 13:55:01 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
2023-02-01 13:55:06 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: socket hang up
    at connResetException (node:internal/errors:691:14)
    at Socket.socketOnEnd (node:_http_client:466:23)
    at Socket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET'
}

Thanks @molensky, judging by the logs, it seems the App won’t connect to the TV. Could you check if the IP address in the logs match those of the TV itself? I can’t remember the setting name, but there is a setting in the TV to allow remote connections. Can you check if that is turned on?

It is possible the API of the TV changed with an update from LG. If this is true, there is not much I can do :frowning: I still have older LG tv’s so I can’t test new WebOS versions unless someone gifts me a brand new tv :upside_down_face:

  • yes, the IP matches the TV
  • yes, it’s on

:cry:

I love your app, but not THAT much :smiley:

I’m reviewing your code and some similar github repositories. Can you give some pointers if there is anything I can try from here? I’m familiar with Postman for REST API’s, not so much with websockets.

I noticed in code, it should prompt for a confirmation on the TV.

    this.lgtv.on('prompt', () => {
      this.log('_connect: [prompt] Please authorize on TV');
      this.setWarning('Please authorise on the TV');
    });

This never happens on the TV. Is this something we could (manually) test/reset/set/…?

I love your app, but not THAT much :smiley:

It was worth a shot :joy:

I noticed in code, it should prompt for a confirmation on the TV.

This only happens if the TV is unknown to the app. This pairing data is stored in a key file, which you should remove before the prompt occurs again. See homey-webos-plus/drivers/webos_plus/lgtv2/lgtv2.js at master · MaxvandeLaar/homey-webos-plus · GitHub

I am using lgtv2 to connect to the TV. I did not wrote this library so my knowledge of this is limited. I did make some changes to make it work on a Homey.

Searching on the web, I found a similar report for HA users. The maintainer claimed with the latest release secure websockets should be used. Is this something you can verify?

Switch to secure WebSockets for compatiblity with latest webOS 22 firmware by Informatic · Pull Request #112 · home-assistant-libs/aiowebostv · GitHub

I found one instance of ws:// and replaced it with wss:// and ran the app from the CLI.
Unfortunately not that simple :smiley:

2023-02-01 15:53:56 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] onInit: Device Ready!
2023-02-01 15:53:56 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] _connect: Connect to TV wss://192.168.###.###
2023-02-01 15:53:57 [err] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] Error: Client network socket disconnected before secure TLS connection was established
    at connResetException (node:internal/errors:691:14)
    at TLSSocket.onConnectEnd (node:_tls_wrap:1585:19)
    at TLSSocket.emit (node:events:538:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ECONNRESET',
  path: null,
  host: '192.168.###.###',
  port: '3000',
  localAddress: undefined
}
2023-02-01 15:54:03 [err] [ManagerDrivers] [webos_plus] [4ae152e2-b24f-4293-822a-9c95aebab735] Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}

Got one step further, needed to update both the scheme and port:

    this.lgtv = require('../lgtv2/lgtv2')({
      url: `wss://${this.getSettings().ipAddress}:3001`,
      keyFile: `/userdata/com.maxvandelaar.webos-plus-keyfile-${this.getSettings().macAddress.replace(/:/g, '')}`
    });

Result:

─────────────── Logging stdout & stderr ───────────────
2023-02-01 16:28:42 [log] [WebosPlus] WebOS Plus is running...
2023-02-01 16:28:43 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] onInit: Device Ready!
2023-02-01 16:28:43 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] _connect: Connect to TV wss://192.168.###.###:3001
2023-02-01 16:28:44 [log] [ManagerDrivers] [webos_plus] WebosPlus Driver has been inited
2023-02-01 16:28:45 [err] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
    at TLSSocket.emit (node:events:526:28)
    at TLSSocket._finishInit (node:_tls_wrap:944:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {
  code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}─────────────── Logging stdout & stderr ───────────────
2023-02-01 16:28:42 [log] [WebosPlus] WebOS Plus is running...
2023-02-01 16:28:43 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] onInit: Device Ready!
2023-02-01 16:28:43 [log] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] _connect: Connect to TV wss://192.168.###.###:3001
2023-02-01 16:28:44 [log] [ManagerDrivers] [webos_plus] WebosPlus Driver has been inited
2023-02-01 16:28:45 [err] [ManagerDrivers] [webos_plus] [ac73fc2c-1c0e-4ae9-bc9f-4c48154bcaec] Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
    at TLSSocket.emit (node:events:526:28)
    at TLSSocket._finishInit (node:_tls_wrap:944:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {
  code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}

Now figuring out how to validate the local certificate.

My LG is not communicating with the app anymore, since the honey software update…
Report: cfa74029-545d-47fa-ace8-f4d3b8b58164

Thanks!

Are you sure you don’t run the Athom flavor? Afaik you can’t create diags from community store apps.