|
| 1 | +How-to: Install LGWebOSRemote on LibreELEC |
| 2 | +========================================== |
| 3 | + |
| 4 | +This guide explains how to install the LGWebOSRemote CLI utility on limited platforms where |
| 5 | +things like Python, PIP and SSDP may not be available or possible to install, but where |
| 6 | +Docker is an option. The guide applies to LibreELEC specifically (which is exactly such a |
| 7 | +limited platform) but should work just as fine for any other platform that fits the criteria. |
| 8 | + |
| 9 | +Pre-requisites |
| 10 | +-------------------- |
| 11 | + |
| 12 | +* Obviously, install the Docker Kodi add-on. |
| 13 | +* Make sure your LibreELEC system has network connectivity. |
| 14 | +* Find out how to use SSH to connect to the LibreELEC system. |
| 15 | +* Connect via SSH, create a directory to hold the Dockerfile, then continue below. |
| 16 | + |
| 17 | +Dockerfile |
| 18 | +--------------- |
| 19 | + |
| 20 | +```dockerfile |
| 21 | +FROM python:3.12 |
| 22 | + |
| 23 | +ENV VIRTUAL_ENV=/opt/venv |
| 24 | +RUN python3 -m venv $VIRTUAL_ENV |
| 25 | +ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 26 | +RUN . /opt/venv/bin/activate && pip install git+https://github.com/klattimer/LGWebOSRemote |
| 27 | +RUN mkdir -m 777 -p /opt/venvs/lgtv/config |
| 28 | +RUN echo '{"mytv" : {"ip": "10.0.0.69", "client-key": "", "mac-address": "34:e6:e6:a5:c8:3c"}}' > /opt/venvs/lgtv/config/config.json |
| 29 | +RUN useradd app |
| 30 | +RUN chown app:app /opt/venvs/lgtv/config |
| 31 | +RUN chown app:app /opt/venvs/lgtv/config/config.json |
| 32 | + |
| 33 | +USER app |
| 34 | + |
| 35 | +RUN . /opt/venv/bin/activate && exec lgtv auth --ssl 10.0.0.69 mytv |
| 36 | +RUN . /opt/venv/bin/activate && exec lgtv setDefault mytv |
| 37 | + |
| 38 | +CMD . /opt/venv/bin/activate && exec lgtv |
| 39 | +``` |
| 40 | + |
| 41 | +You'll need to adapt the Dockerfile slightly to fit your system: |
| 42 | + |
| 43 | +* Change the `ip` and `mac-address` settings in the JSON array that is written to `config.json`. |
| 44 | +* Change the IP and TV name in the `auth` command. |
| 45 | +* If you changed the TV name, also change it in the `setDefault` command right below. |
| 46 | + |
| 47 | +Building it |
| 48 | +--------------- |
| 49 | + |
| 50 | +```bash |
| 51 | +docker build --network=host -t lgtv/remote . |
| 52 | +``` |
| 53 | + |
| 54 | +* The `--network=host` part is vital! |
| 55 | +* While building, your TV will prompt you to authenticate an app. Be ready to accept that dialog. |
| 56 | +* Once built, the Docker image contains configuration to operate one TV. |
| 57 | + |
| 58 | +Running it |
| 59 | +--------------- |
| 60 | + |
| 61 | +```bash |
| 62 | +# example with screenOn command |
| 63 | +docker run -t --rm lgtv/remote lgtv --ssl screenOn |
| 64 | +``` |
| 65 | + |
| 66 | +* The `--rm` is added to avoid leaving one dead container for every execution. |
| 67 | +* The `-t` is optional but nice for continuous feedback. |
| 68 | + |
| 69 | +The workarounds |
| 70 | +------------------------- |
| 71 | + |
| 72 | +1. LibreELEC won't allow network scan with SSDP to discover the TV, so you can't use `lgtv scan` - you have to use the IP manually. |
| 73 | +2. Docker (or at least the base image used here) won't allow the configuration file to be automatically created - the build routine must create it. |
| 74 | +3. Docker won't persist the configuration file changes so you can't store the client key - the `auth` step is done when building to make sure the built image contains the right configuration. |
| 75 | +4. The base image has no home directory so the configuration file has to be written to `/opt/venvs/lgtv/config/config.json`. |
0 commit comments