Hi All,
I am a proud owner of a new LG television, which I choose primarily for WebOs. Integrating it in Home Assistant seemed easy, all was working almost instantly, until I turned it off and was trying to turn it on again.
First stop are the Docs, nobody wants to be that RTFM guy. The Docs clearly describe that the way to go is using Wake_On_Lan. This is also what I have set up. From the description in the docs, all seemed fine. Next stop, Google, StackExchange, etc. and it was not easy to troubleshoot the problem. However, after three hours I found the problem:
I am running Home Assistant inside a Docker container and I am using Traefik as a reversed proxy, including a virtualized network in Docker.
This last thing is the problem. Wake On Lan (WOL) uses so called magic packages and these cannot be send directly from a virtualized docker Network to devices outside of that network. To solve this, you can:
- set Home Assistant to use the host network. This does however give problems with my reversed proxy (Traefik).
- Use some other computer to do the WOL call.
To help others, hopefully saving some time, I will describe here my solution which helped me turn on the LG television.
Add Wake On Lan RESTful service to the Docker compose:
wol:
container_name: wake-on-lan
image: anjia0532/wakeonlan:latest
restart: unless-stopped
network_mode: host
labels:
- "traefik.enable=false"
This adds a server that is running on your Docker host, sharing the host network and serving a RESTful api to do WOL. This can now work:
curl -XPOST -d '{"macAddress":"AB:CD:EF:12:34:56"}' http://<your_server_ip>:8080/api/v1/wake
Now we can setup Home Assistant to use the restful call. I have added three entries into my secrets.yaml:
# wol tv control
wol_api: "http://xxx.xxx.xxx.xxx:8080/api/v1/wake"
wol_payload_tv: '{"macAddress":"xx:xx:xx:xx:xx:xx"}'
webostv_ip: xxx.xxx.xxx.xxx
And finally added the webostv to configuration.yaml:
rest_command:
turn_tv_on:
url: !secret wol_api
method: POST
payload: !secret wol_payload_tv
webostv:
host: !secret webostv_ip
name: LG Television
turn_on_action:
service: rest_command.turn_tv_on
customize:
sources:
- HDMI 2
- Netflix
- Prime Video
Make sure that your TV has the Wake On Lan feature turned on. They are in:
Connection -> Mobile Connection Management -> TV On with Mobile
I hope that others, having the same troubles with their LG TV find this post useful and save them some time. I could add these to the manual, what do you guys think?
Cheers,
Dennis