LG WebOS TV and GNU Emacs

Modern LG TVs with WebOS allow remote control via websockets. Since this is a web technology, you might want to automate this using Node JS [1]. However, if you want a fair balance between scripting and interactive use, Emacs will serve you better.

Toast (top right) sent from Emacs

 

Completing LG TV commands in Emacs

Steps

  1. Install package websocket from ELPA.
    M-x package-install RET websocket RET 

  2. Download tv.el and pairing.json
  3. Load tv.el
    M-x load-library RET tv RET 

  4. Ensure variable lgtv--pairing-json is pointing to pairing.json file.
  5. Run M-x lgtv-command
  6. Enter a command for LG TV. Use TAB for completion.
  7. Enter a JSON object for command parameter. Leave empty if the command doesn't require a parameter. (Note: Remember to quote the keys in JSON.)

;; Sample payload passed to TV. You need to provide URI (without ssap://) and payload parts
 
;; Show toast
{ "id": "0c8b18a10002", "type": "request", "uri": "ssap://system.notifications/createToast","payload": {"message":"TV is being controlled by Emacs"} }
 
;; Play youtube video. Note - some content might not work
{ "id": "0c8b18a10002", "type": "request", "uri": "ssap://system.launcher/launch","payload": {"contentId":"dQw4w9WgXcQ", "id": "youtube.leanback.v4"} }
 

 

Code

https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/tv.el

https://gitlab.com/atamariya/emacs/-/blob/dev/etc/tv/pairing.json


References

  1. https://github.com/msloth/lgtv.js
  2. Commands list 
  3. Emacs websocket

 

Comments

Popular posts from this blog

GNU Emacs as a Comic Book Reader

HTML Renderer (Emacs)

Mozilla Readability in GNU Emacs