LG Webos MQTT Flow

This flow adds the ability to control LG tv`s (on-off, Toast message) based on WebOS. I have tried it on Webos2.0 but I am sure it should work with WebOs3.0.

First step is to inject the DOAuth flow and Authorize on TV set to get your client-key, open the KeepAlive node and paste it in the client-key.

Change the IP address and mac address in the [WOL lgtv] node to point to your LGTV and thats it. Test with the two inject nodes (message, TurnOFF)

Will add more functions like Channels and Inputs soon

Based on https://github.com/msloth/lgtv.js/blob/master/index.js

[{"id":"f723de7.6ca5a2","type":"websocket in","z":"2a447062.47763","name":"","server":"","client":"67b9a5c9.74c77c","x":255.83668518066406,"y":504.20849609375,"wires":[["60a242f3.ed892c","1eabc472.bb13dc"]]},{"id":"d71d58e1.f19878","type":"websocket out","z":"2a447062.47763","name":"Websocket 192.168.2.90:3000","server":"","client":"67b9a5c9.74c77c","x":1425.8368377685547,"y":519.9583129882812,"wires":[]},{"id":"5fe57973.c27878","type":"inject","z":"2a447062.47763","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":193.82984924316406,"y":275.97222900390625,"wires":[["ad94ba81.2c43f8"]]},{"id":"ad94ba81.2c43f8","type":"function","z":"2a447062.47763","name":"Do Auth","func":"var mess = \n{\n\t\"type\": \"register\",\n\t\"id\": \"register_0\",\n\t\"payload\": {\n\t\t\"forcePairing\": false,\n\t\t\"pairingType\": \"PROMPT\",\n\t\t\"manifest\": {\n\t\t\t\"manifestVersion\": 1,\n\t\t\t\"appVersion\": \"1.1\",\n\t\t\t\"signed\": {\n\t\t\t\t\"created\": \"20140509\",\n\t\t\t\t\"appId\": \"com.lge.test\",\n\t\t\t\t\"vendorId\": \"com.lge\",\n\t\t\t\t\"localizedAppNames\": {\n\t\t\t\t\t\"\": \"LG Remote App\",\n\t\t\t\t\t\"ko-KR\": \"리모컨 앱\",\n\t\t\t\t\t\"zxx-XX\": \"ЛГ Rэмotэ AПП\"\n\t\t\t\t},\n\t\t\t\t\"localizedVendorNames\": {\n\t\t\t\t\t\"\": \"LG Electronics\"\n\t\t\t\t},\n\t\t\t\t\"permissions\": [\"TEST_SECURE\", \"CONTROL_INPUT_TEXT\", \"CONTROL_MOUSE_AND_KEYBOARD\", \"READ_INSTALLED_APPS\", \"READ_LGE_SDX\", \"READ_NOTIFICATIONS\", \"SEARCH\", \"WRITE_SETTINGS\", \"WRITE_NOTIFICATION_ALERT\", \"CONTROL_POWER\", \"READ_CURRENT_CHANNEL\", \"READ_RUNNING_APPS\", \"READ_UPDATE_INFO\", \"UPDATE_FROM_REMOTE_APP\", \"READ_LGE_TV_INPUT_EVENTS\", \"READ_TV_CURRENT_TIME\"],\n\t\t\t\t\"serial\": \"2f930e2d2cfe083771f68e4fe7bb07\"\n\t\t\t},\n\t\t\t\"permissions\": [\"LAUNCH\", \"LAUNCH_WEBAPP\", \"APP_TO_APP\", \"CLOSE\", \"TEST_OPEN\", \"TEST_PROTECTED\", \"CONTROL_AUDIO\", \"CONTROL_DISPLAY\", \"CONTROL_INPUT_JOYSTICK\", \"CONTROL_INPUT_MEDIA_RECORDING\", \"CONTROL_INPUT_MEDIA_PLAYBACK\", \"CONTROL_INPUT_TV\", \"CONTROL_POWER\", \"READ_APP_STATUS\", \"READ_CURRENT_CHANNEL\", \"READ_INPUT_DEVICE_LIST\", \"READ_NETWORK_STATE\", \"READ_RUNNING_APPS\", \"READ_TV_CHANNEL_LIST\", \"WRITE_NOTIFICATION_TOAST\", \"READ_POWER_STATE\", \"READ_COUNTRY_INFO\"],\n\t\t\t\"signatures\": [{\n\t\t\t\t\"signatureVersion\": 1,\n\t\t\t\t\"signature\": \"eyJhbGdvcml0aG0iOiJSU0EtU0hBMjU2Iiwia2V5SWQiOiJ0ZXN0LXNpZ25pbmctY2VydCIsInNpZ25hdHVyZVZlcnNpb24iOjF9.hrVRgjCwXVvE2OOSpDZ58hR+59aFNwYDyjQgKk3auukd7pcegmE2CzPCa0bJ0ZsRAcKkCTJrWo5iDzNhMBWRyaMOv5zWSrthlf7G128qvIlpMT0YNY+n/FaOHE73uLrS/g7swl3/qH/BGFG2Hu4RlL48eb3lLKqTt2xKHdCs6Cd4RMfJPYnzgvI4BNrFUKsjkcu+WD4OO2A27Pq1n50cMchmcaXadJhGrOqH5YmHdOCj5NSHzJYrsW0HPlpuAx/ECMeIZYDh6RMqaFM2DXzdKX9NmmyqzJ3o/0lkk/N97gfVRLW5hA29yeAwaCViZNCP8iC9aO0q9fQojoa7NQnAtw==\"\n\t\t\t}]\n\t\t}\n\t}\n}\nreturn mess;","outputs":1,"noerr":0,"x":700.8402557373047,"y":272.2917022705078,"wires":[["d71d58e1.f19878"]]},{"id":"dd73ec87.9600a","type":"function","z":"2a447062.47763","name":"KeepAlive","func":"var mess = \n{\n\t\"type\": \"register\",\n\t\"id\": \"register_0\",\n\t\"payload\": {\n\t\t\"forcePairing\": false,\n\t\t\"pairingType\": \"PROMPT\",\n\t\t\"client-key\": \"b4383536f5c76d79442e3e98e2d68838\",\n\t\t\"manifest\": {\n\t\t\t\"manifestVersion\": 1,\n\t\t\t\"appVersion\": \"1.1\",\n\t\t\t\"signed\": {\n\t\t\t\t\"created\": \"20140509\",\n\t\t\t\t\"appId\": \"com.lge.test\",\n\t\t\t\t\"vendorId\": \"com.lge\",\n\t\t\t\t\"localizedAppNames\": {\n\t\t\t\t\t\"\": \"LG Remote App\",\n\t\t\t\t\t\"ko-KR\": \"리모컨 앱\",\n\t\t\t\t\t\"zxx-XX\": \"ЛГ Rэмotэ AПП\"\n\t\t\t\t},\n\t\t\t\t\"localizedVendorNames\": {\n\t\t\t\t\t\"\": \"LG Electronics\"\n\t\t\t\t},\n\t\t\t\t\"permissions\": [\"TEST_SECURE\", \"CONTROL_INPUT_TEXT\", \"CONTROL_MOUSE_AND_KEYBOARD\", \"READ_INSTALLED_APPS\", \"READ_LGE_SDX\", \"READ_NOTIFICATIONS\", \"SEARCH\", \"WRITE_SETTINGS\", \"WRITE_NOTIFICATION_ALERT\", \"CONTROL_POWER\", \"READ_CURRENT_CHANNEL\", \"READ_RUNNING_APPS\", \"READ_UPDATE_INFO\", \"UPDATE_FROM_REMOTE_APP\", \"READ_LGE_TV_INPUT_EVENTS\", \"READ_TV_CURRENT_TIME\"],\n\t\t\t\t\"serial\": \"2f930e2d2cfe083771f68e4fe7bb07\"\n\t\t\t},\n\t\t\t\"permissions\": [\"LAUNCH\", \"LAUNCH_WEBAPP\", \"APP_TO_APP\", \"CLOSE\", \"TEST_OPEN\", \"TEST_PROTECTED\", \"CONTROL_AUDIO\", \"CONTROL_DISPLAY\", \"CONTROL_INPUT_JOYSTICK\", \"CONTROL_INPUT_MEDIA_RECORDING\", \"CONTROL_INPUT_MEDIA_PLAYBACK\", \"CONTROL_INPUT_TV\", \"CONTROL_POWER\", \"READ_APP_STATUS\", \"READ_CURRENT_CHANNEL\", \"READ_INPUT_DEVICE_LIST\", \"READ_NETWORK_STATE\", \"READ_RUNNING_APPS\", \"READ_TV_CHANNEL_LIST\", \"WRITE_NOTIFICATION_TOAST\", \"READ_POWER_STATE\", \"READ_COUNTRY_INFO\"],\n\t\t\t\"signatures\": [{\n\t\t\t\t\"signatureVersion\": 1,\n\t\t\t\t\"signature\": \"eyJhbGdvcml0aG0iOiJSU0EtU0hBMjU2Iiwia2V5SWQiOiJ0ZXN0LXNpZ25pbmctY2VydCIsInNpZ25hdHVyZVZlcnNpb24iOjF9.hrVRgjCwXVvE2OOSpDZ58hR+59aFNwYDyjQgKk3auukd7pcegmE2CzPCa0bJ0ZsRAcKkCTJrWo5iDzNhMBWRyaMOv5zWSrthlf7G128qvIlpMT0YNY+n/FaOHE73uLrS/g7swl3/qH/BGFG2Hu4RlL48eb3lLKqTt2xKHdCs6Cd4RMfJPYnzgvI4BNrFUKsjkcu+WD4OO2A27Pq1n50cMchmcaXadJhGrOqH5YmHdOCj5NSHzJYrsW0HPlpuAx/ECMeIZYDh6RMqaFM2DXzdKX9NmmyqzJ3o/0lkk/N97gfVRLW5hA29yeAwaCViZNCP8iC9aO0q9fQojoa7NQnAtw==\"\n\t\t\t}]\n\t\t}\n\t}\n}\nreturn mess;","outputs":1,"noerr":0,"x":906.8298797607422,"y":504.2882070541382,"wires":[["d71d58e1.f19878"]]},{"id":"712f057c.339e1c","type":"inject","z":"2a447062.47763","name":"","topic":"","payload":"","payloadType":"str","repeat":"10","crontab":"","once":false,"x":597.8298187255859,"y":428.96875,"wires":[["dd73ec87.9600a"]]},{"id":"d4a07582.0abb48","type":"inject","z":"2a447062.47763","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":218.84027099609375,"y":617.96533203125,"wires":[["fee565c1.f7cfe8"]]},{"id":"fee565c1.f7cfe8","type":"function","z":"2a447062.47763","name":"Message","func":"var mess =\n{\n\t\"id\": \"1\",\n\t\"type\": \"request\",\n\t\"uri\": \"ssap://system.notifications/createToast\",\n\t\"payload\": {\"message\": \"test\"}\n};\nreturn mess;","outputs":1,"noerr":0,"x":544.8402557373047,"y":623.9583740234375,"wires":[["dd73ec87.9600a","4f78df9c.93904"]]},{"id":"9eabf51c.100118","type":"inject","z":"2a447062.47763","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"x":230.89581298828125,"y":695.8889465332031,"wires":[["2140e707.a18d48"]]},{"id":"2140e707.a18d48","type":"function","z":"2a447062.47763","name":"TurnOFF","func":"var mess =\n{\n\t\"id\": \"1\",\n\t\"type\": \"request\",\n\t\"uri\": \"ssap://system/turnOff\"\n\t\n};\nreturn mess;","outputs":1,"noerr":0,"x":533.8957366943359,"y":694.8819580078125,"wires":[["4f78df9c.93904","dd73ec87.9600a"]]},{"id":"b2df9d03.86f89","type":"mqtt in","z":"2a447062.47763","name":"From LGTV","topic":"LGtv/Toast/","qos":"0","broker":"fea649f2.426718","x":216.89581298828125,"y":814.8889465332031,"wires":[["236f0054.24264"]]},{"id":"236f0054.24264","type":"template","z":"2a447062.47763","name":"Create Payload","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n\t\"id\": \"1\",\n\t\"type\": \"request\",\n\t\"uri\": \"ssap://system.notifications/createToast\",\n\t\"payload\": {\"message\": \"{{payload}}\"}\n}","x":556.8299407958984,"y":779.9306640625,"wires":[["dbc51a31.155d78","dd73ec87.9600a"]]},{"id":"f16a9755.cbaf78","type":"debug","z":"2a447062.47763","name":"","active":false,"console":"false","complete":"true","x":909.8403167724609,"y":698.3334045410156,"wires":[]},{"id":"dbc51a31.155d78","type":"function","z":"2a447062.47763","name":"Strip Payload","func":"var msgs = JSON.parse(msg.payload)\nreturn msgs;","outputs":1,"noerr":0,"x":778.8265228271484,"y":782.611083984375,"wires":[["f16a9755.cbaf78","4f78df9c.93904"]]},{"id":"493d47e8.92f8f8","type":"mqtt in","z":"2a447062.47763","name":"From LGTV","topic":"LGtv/power/","qos":"0","broker":"fea649f2.426718","x":206.89581298828125,"y":896.8889465332031,"wires":[["c32d5926.c45258"]]},{"id":"c32d5926.c45258","type":"switch","z":"2a447062.47763","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","outputs":2,"x":530.8298187255859,"y":873.0799560546875,"wires":[["8cfc21e5.d8c45","dd73ec87.9600a","f767ddf8.c860e"],["23375f2a.86e59","cc8d8afd.622bf8"]]},{"id":"8cfc21e5.d8c45","type":"function","z":"2a447062.47763","name":"TurnOFF","func":"var mess =\n{\n\t\"id\": \"1\",\n\t\"type\": \"request\",\n\t\"uri\": \"ssap://system/turnOff\"\n\t\n};\nreturn mess;","outputs":1,"noerr":0,"x":763.8958129882812,"y":846.888916015625,"wires":[["4f78df9c.93904"]]},{"id":"23375f2a.86e59","type":"wake on lan","z":"2a447062.47763","mac":"3C:CD:93:DA:59:1D","name":"wol lgtv","x":768.8264312744141,"y":905.7847595214844,"wires":[]},{"id":"60a242f3.ed892c","type":"switch","z":"2a447062.47763","name":"","property":"error","propertyType":"msg","rules":[{"t":"cont","v":"401","vt":"str"}],"checkall":"true","outputs":1,"x":586.8333587646484,"y":505.40972900390625,"wires":[["dd73ec87.9600a"]]},{"id":"a91a1db6.fa165","type":"ping","z":"2a447062.47763","name":"","host":"192.168.2.90","timer":"20","x":223.83331298828125,"y":1084.5729217529297,"wires":[["bcae0e57.a78fc","a53d9c56.5c942"]]},{"id":"4f78df9c.93904","type":"delay","z":"2a447062.47763","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1149.8265838623047,"y":659.8194732666016,"wires":[["d71d58e1.f19878"]]},{"id":"8c763871.e89058","type":"switch","z":"2a447062.47763","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"neq","v":"0","vt":"num"}],"checkall":"false","outputs":2,"x":608.8402862548828,"y":1083.0764440489406,"wires":[["f767ddf8.c860e"],["cc8d8afd.622bf8"]]},{"id":"daa02bcc.ab4158","type":"mqtt out","z":"2a447062.47763","name":"","topic":"LGtv/power/status","qos":"0","retain":"","broker":"fea649f2.426718","x":1110.8300018310547,"y":1053.972152709961,"wires":[]},{"id":"f767ddf8.c860e","type":"function","z":"2a447062.47763","name":"False OFF","func":"var msgs = { payload: \"false\" };\nreturn msgs;","outputs":1,"noerr":0,"x":814.8957977294922,"y":1087.111068725586,"wires":[["daa02bcc.ab4158"]]},{"id":"cc8d8afd.622bf8","type":"function","z":"2a447062.47763","name":"True ON","func":"var msgs = { payload: \"true\" };\nreturn msgs;","outputs":1,"noerr":0,"x":808.8957977294922,"y":988.1110687255859,"wires":[["daa02bcc.ab4158"]]},{"id":"bcae0e57.a78fc","type":"rbe","z":"2a447062.47763","name":"","func":"rbe","gap":"","start":"","inout":"out","x":419.8298797607422,"y":1083.0659637451172,"wires":[["8c763871.e89058"]]},{"id":"a53d9c56.5c942","type":"debug","z":"2a447062.47763","name":"","active":true,"console":"false","complete":"payload","x":459.89585876464844,"y":994.2222290039062,"wires":[]},{"id":"1eabc472.bb13dc","type":"debug","z":"2a447062.47763","name":"","active":false,"console":"false","complete":"true","x":409.89581298828125,"y":387.22222900390625,"wires":[]},{"id":"67b9a5c9.74c77c","type":"websocket-client","z":"2a447062.47763","path":"ws://192.168.2.90:3000","wholemsg":"true"},{"id":"fea649f2.426718","type":"mqtt-broker","z":"2a447062.47763","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

Flow Info

Created 8 years, 1 month ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x3)
  • delay (x1)
  • function (x8)
  • inject (x4)
  • mqtt in (x2)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • rbe (x1)
  • switch (x3)
  • template (x1)
  • websocket in (x1)
  • websocket out (x1)
  • websocket-client (x1)
Other

Tags

  • LG
  • webos
  • mqtt
  • websocket
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option