Home Assistant¶
Home Assistant is a popular, open-source home automation platform designed with a local-first philosophy, prioritizing privacy, reliability, and full control over your smart home ecosystem.
Glasshouse bridges your rooted LG webOS TV directly into Home Assistant, transforming the TV into a fully integrated smart home device:
- Comprehensive Telemetry & Readings: Exposes real-time system metrics (SoC temperature, CPU and memory load), HDMI link and video signal diagnostics (resolution, frame rate, HDR/Dolby Vision, VRR, ALLM), OLED panel health (cumulative hours, pixel refresher countdowns, cycle history), and active apps.
- Bi-directional Control: Provides complete local control from your Home Assistant dashboard and automations — power states, input switching, volume and mute, playback controls, picture presets, screen blanking, and launching apps.
- Remote & Cloud Control: With Home Assistant Cloud (Nabu Casa) or your own secure remote connection (WireGuard, Cloudflare Tunnel), you can securely monitor and control your TV from anywhere in the world, without exposing the TV's web dashboard or root shell directly to the internet.
Every entity published by the bridge is detailed in Entities, and triggering automations from Magic Remote button presses is covered in Remote Button Events.
Why MQTT?¶
Home Assistant connects to local devices and bridges using standard communication protocols. Glasshouse uses MQTT (Message Queuing Telemetry Transport), an industry-standard, lightweight, event-driven messaging protocol designed for IoT and home automation.
In this setup:
- The TV as Publisher & Subscriber: The TV publishes state updates (such as power state, active input, or volume) whenever they change, and subscribes to command topics to receive actions from Home Assistant.
- The MQTT Broker: Communication flows through an MQTT broker — a lightweight server on your local network that relays messages between devices. The standard choice for Home Assistant is the official Mosquitto broker add-on, which can be installed with a single click.
- Automatic MQTT Discovery: Glasshouse follows Home Assistant's MQTT Discovery standard. As soon as the TV connects to the broker, it publishes configuration payloads that automatically register the TV and all its sensors, switches, buttons, and select menus. No manual YAML configuration is required.
Setup & Configuration¶
Connecting Glasshouse to Home Assistant takes only a few minutes.
Prerequisites¶
- An operational Home Assistant installation.
- An MQTT broker running on your network. If you do not have one yet:
- In Home Assistant, navigate to Settings → Add-ons → Add-on Store.
- Search for Mosquitto broker, install it, and start the add-on.
- Navigate to Settings → Devices & Services and ensure the MQTT integration is configured (Home Assistant prompts to set it up automatically once Mosquitto is running).
- Dedicated MQTT credentials for the TV (recommended; see Hardening the MQTT bridge).
Setting it up from the dashboard¶
- Open the dashboard in a browser, then navigate to the HA & MQTT tab (
/?tab=mqtt). - Fill in the broker address, port (
1883), and credentials. - Switch MQTT bridge to On and save.
The server saves config.json on the TV and restarts itself; the dashboard reconnects automatically after a few seconds. Home Assistant discovers the TV within seconds of the bridge connecting under Settings → Devices & Services → MQTT.
The MQTT panel displays a live connection visual between the TV and MQTT server, animating telemetry publishes, tracking reachability and round-trip ping latency automatically, and surfacing rejected credentials or unreachable hosts immediately.
Setting it up from a config file¶
For setting up multiple TVs from one computer or keeping settings under version control, configure config.json directly:
From server/:
cp ../config.example.json config.json
Set the broker details under mqtt and set enabled to true, then run ./deploy.sh <tv-ip>. Leaving device.name and device.model empty lets the TV report its own model and firmware at runtime.
deploy.sh only installs this file if the TV does not already have one, preventing settings saved from the dashboard from being overwritten. To replace an existing configuration, edit it through the dashboard or remove /var/lib/tvweb/config.json first.
Multiple TVs on the same broker¶
Each TV on the same broker needs a unique topicPrefix and device.id, otherwise they overwrite each other's state and disconnect each other. Both are editable from each TV's own dashboard.
For config-file deployments, deploy.sh checks for server/config.<tv-ip>.json before falling back to server/config.json, keeping per-TV settings from being overwritten by a shared file.
Which settings live where?¶
The dashboard can change the broker, credentials, topic prefix and device identity, the settings that decide where telemetry goes, along with the Home Assistant API URL and token used by screen savers and Glasshouse Home's values at a glance.
port, host, allowControl, allowPower and token are file-only. They decide who can reach the server at all, and a web UI able to widen its own exposure would defeat the point of setting them. syslog is file-only too. allowTileHiding, allowExperimentalScreensavers, allowNetworkDebugger, prometheus.enabled and ntp can be set in config.json or from the Server tab, and iconServer from the HA & MQTT tab (App icons).
Edit those in config.json and redeploy, or edit /var/lib/tvweb/config.json on the TV and restart.
apps.hosts is file-only as well. apps.hosts lists the hostnames, beyond IP addresses and localhost, that may be used to reach the dashboard when installing apps (e.g. "apps": { "hosts": ["lgtv.local"] }). apps.repos lists further catalogs served over HTTPS in Homebrew Channel format, which the Apps tab's Other app catalogs also adds to and removes from. apps.sideload: true allows installing from a URL or an uploaded file without a token; with a token set or from the TV itself, it is allowed already.
fetch.ip is file-only too: "fetch": { "ip": "4" } or "6" makes the TV's curl use that address family first. Without it, a connection that fails is retried with -6, then -4.
allowPower defaults to true: who on the network can use controls is decided by network exposure and token. Setting "allowPower": false hides and refuses power off, power on, and reboot, both in the dashboard and in Home Assistant.
Note
Give the TV its own MQTT user with a restricted topic ACL rather than reusing the main Home Assistant credentials. See Hardening the MQTT bridge.
Running one half without the other¶
| Mode | web.enabled |
mqtt.enabled |
|---|---|---|
| Dashboard and MQTT | true |
true |
| Dashboard only (default) | true |
false |
| MQTT only | false |
true |
With the dashboard disabled, the server acts purely as an MQTT bridge with no web interface, which is the safer shape if everything is driven from Home Assistant (the dashboard is an unauthenticated control endpoint unless token is set). Note that this also removes the settings UI, so an MQTT-only install is configured by file. With both disabled, the server exits rather than idling.
PicCap ambient lighting¶
PicCap captures the TV's screen for a Hyperion server, which drives an ambient light behind the TV. Where PicCap is installed, the System tab has a PicCap capture switch that starts and stops capture, and Home Assistant receives a PicCap Capture switch under Controls & Media. Nothing is asked of PicCap on a TV without it. Its Home Assistant entity can be switched off like any other, which also stops the server polling PicCap's state every 30 seconds.
The retained state topic <topicPrefix>/state/piccap/power carries ON or OFF, and the command topic <topicPrefix>/command/piccap/power accepts ON or OFF (commands require allowControl). Telemetry includes the boolean piccap.power while PicCap answers.
Hue Sync¶
Where the Hue Sync app is installed, the System tab has a Hue Sync streaming switch and Home Assistant receives a Hue Sync switch under Controls & Media, which starts and stops its streaming to Philips Hue and Ambience lights. Nothing is asked of Hue Sync on a TV without it. Its Home Assistant entity can be switched off like any other, which also stops the server polling Hue Sync's state every 30 seconds.
The retained state topic <topicPrefix>/state/huesync/power carries ON or OFF, and the command topic <topicPrefix>/command/huesync/power accepts ON or OFF (commands require allowControl). Telemetry includes the boolean huesync.streaming while Hue Sync answers. See Hue Sync for setup and automation examples.
Using MQTT without Home Assistant¶
The bridge is a plain MQTT publisher, so any client that speaks MQTT can read it. Telemetry is published as JSON to <topicPrefix>/telemetry, availability to <topicPrefix>/status, and commands are accepted on <topicPrefix>/command/*.
mosquitto_sub -h <broker> -t 'lgtv/#' -v
Node-RED, Telegraf into InfluxDB, or scripts subscribing to that topic work the same way. The Home Assistant Discovery messages are simply ignored by non-Home Assistant clients.
Reading Home Assistant entities¶
Home Assistant API and MQTT bridge do separate jobs and are arranged in two sections on the HA & MQTT tab (/?tab=mqtt):
- MQTT bridge publishes the TV's telemetry, sensors, and settings to your broker and receives remote control commands from Home Assistant.
- Home Assistant API connects straight from the TV to Home Assistant over HTTP/HTTPS (using Home Assistant's REST API, without MQTT) so built-in screen savers, custom QML screen savers and Glasshouse Home's values at a glance can read live entities from your smart home.

The HA & MQTT tab separates the MQTT bridge (controlling and observing the TV) from the Home Assistant API (reading Home Assistant entities into screen savers and Glasshouse Home).
Configuring the Home Assistant API¶
- In Home Assistant, open your profile (bottom-left) → Security → Long-Lived Access Tokens → Create Token and copy the token.
- Open Glasshouse in a browser and navigate to HA & MQTT → Home Assistant API.
- Enter your Home Assistant address (for example
http://192.168.1.10:8123orhttp://homeassistant.local:8123) and paste the Long-Lived Access Token (or sethomeAssistant.urlandhomeAssistant.tokeninconfig.json). - Click Save. The settings apply at once, without restarting the server, and Glasshouse checks the connection. The Connection box beside the settings draws the TV and Home Assistant as the MQTT bridge's box draws the TV and its broker: the link reads Reachable with Home Assistant's response time and how long ago Glasshouse last read an entity, Off, or Unreachable with the reason. You can switch the Home Assistant API button off at any time to disable Home Assistant screen savers while keeping your saved address and token.

Once enabled and connected, the API is used in two places. While it is off or unconfigured, neither offers it.
On Glasshouse Home, values at a glance shows up to four entities beside the clock, picked on the Home tab: a bin collection, a parcel on its way, a share price.
On the Screensaver tab, two Home Assistant screen savers appear:
- Home Assistant: Ambient — shows the TV clock, date, and up to three configurable entities with optional custom display labels.
- Home Assistant: Data Display — cycles sequentially through 2 to 100 entities one at a time on black.
Custom QML screen savers added on the TV can read Home Assistant entities too. Each declares what it needs in saver.json, and Glasshouse serves only those entity IDs at local URLs, so the Home Assistant token never reaches a QML file. Those URLs carry Glasshouse's own dashboard token, where one is set, as the stats URL does. A saver that wants every value at once declares ha-all instead and is handed one address, /api/homeassistant, which answers with all of its entities in a single request. See Screen saver design principles for the manifest and QML format.
Entities¶
Once connected to the MQTT broker, Home Assistant discovers the TV as a single device. Entities lists every one it publishes.
Entity Selection¶
You can choose which entity categories are published from the HA & MQTT tab in the dashboard (/?tab=mqtt), or fine-tune individual entities. When a category or entity is disabled, tvweb publishes an empty discovery payload so Home Assistant unregisters the entity immediately, without leaving orphaned unavailable entities.
Categories:
* Controls & Media (controls): Power, volume, mute, playback buttons, apps, and input sources.
* OLED Care (oled): Panel on-time, pixel refresher countdowns, and burn-in protections.
* Video & HDMI Signal (video): Active picture mode, dynamic range, refresh rate, VRR, ALLM, and link mode.
* System & Telemetry (system): CPU, RAM, swap, SoC temperature, network rates, and storage health.
* Diagnostics & Settings (diagnostics): Standby light, logo light, sleep timer, ad blocker, and update status.
PicCap¶
Where PicCap is installed, a PicCap Capture switch is discovered while PicCap answers on the TV, and removed when it stops answering or is uninstalled. It is in Controls & Media and can be switched off there. It uses <topicPrefix>/state/piccap/power for state and <topicPrefix>/command/piccap/power for control, both ON or OFF. See PicCap and ambient light for full setup instructions, Hyperion configuration, and automation examples.
Hue Sync¶
Where the Hue Sync app is installed, a Hue Sync switch is discovered while its service answers on the TV, and removed when it stops answering or the app goes. It is in Controls & Media and can be switched off there. It uses <topicPrefix>/state/huesync/power for state and <topicPrefix>/command/huesync/power for control, both ON or OFF. See Hue Sync for setup and automation examples.
Multiple TVs¶
Each TV on the same broker needs a unique topicPrefix and device.id in its
config, otherwise they overwrite each other's state and disconnect each other.
See the README for a config example and the deploy.sh per-IP config lookup.
App icons for launchers¶
Glasshouse can share the TV's app icons with other devices on the network, so a dashboard or a launcher elsewhere can show the TV's apps as tiles. Home Assistant does not draw them by itself: the Launch App entity keeps its one icon and lists apps by name. The icons' addresses arrive as attributes of that entity, for a dashboard card or another app to use.
Switching it on¶
- Open the dashboard's MQTT tab, set Share app icons to Enabled, and select Save & restart.
- The TV then serves each installed app's icon at
http://<tv-ip>:8082/icons/<appId>.png. Anyone on the network can fetch them, and so tell which apps are installed.
What Home Assistant receives¶
Open Launch App (select.lg_tv_app) and expand Attributes, or find it under Developer tools → States:
- App ids (
app_ids): each app's name and its app id, which stays the same when an app's title changes. - App icons (
app_icons): each app id and its icon's address, only while icons are shared. - App colors (
app_colors): each app id and the background colour the app declares, as#rrggbb, where it declares one.
Adding the icons to a dashboard¶
- Open a dashboard, select the pencil (Edit dashboard), then Add card.
- Pick Manual at the bottom of the list, which takes the card as YAML.
- Paste one of the cards below, change
select.lg_tv_appto the TV's own entity if its device id is notlg_tv, and select Save.
Every installed app, with its icon and name:
type: markdown
title: TV apps
content: >
{% set ids = state_attr('select.lg_tv_app', 'app_ids') or {} %}
{% set icons = state_attr('select.lg_tv_app', 'app_icons') or {} %}
{% for name, id in ids.items() if id in icons %}
<img src="{{ icons[id] }}" height="48" alt=""> {{ name }}
{% endfor %}
A row of tiles that each open an app. Each option is a name from the Launch App list, and each image the address from App icons:
type: grid
columns: 4
square: true
cards:
- type: picture
image: http://192.168.1.20:8082/icons/netflix.png
tap_action:
action: perform-action
perform_action: select.select_option
target:
entity_id: select.lg_tv_app
data:
option: Netflix
- type: picture
image: http://192.168.1.20:8082/icons/youtube.leanback.v4.png
tap_action:
action: perform-action
perform_action: select.select_option
target:
entity_id: select.lg_tv_app
data:
option: YouTube
The icons are plain http. A browser showing Home Assistant over https, as through Home Assistant Cloud, blocks them as mixed content, and the cards show no pictures there.
Example automations¶
1. Automatically Blank Screen When Playing Music (Spotify / AirPlay)¶
Save OLED panel hours and eliminate burn-in risk when streaming audio:
alias: "TV: Turn Off Screen for Music"
trigger:
- platform: state
entity_id: sensor.lg_tv_active_app
to: "spotify"
for:
seconds: 30
condition:
- condition: state
entity_id: switch.lg_tv_display_panel
state: "on"
action:
- service: switch.turn_off
target:
entity_id: switch.lg_tv_display_panel
2. Dim Cinema Lighting on Dolby Vision Playback¶
Trigger an ambient lighting scene whenever 4K Dolby Vision playback begins:
alias: "Cinema: Dim Lights on Dolby Vision"
trigger:
- platform: state
entity_id: sensor.lg_tv_dynamic_range
to: "Dolby Vision"
action:
- service: scene.turn_on
target:
entity_id: scene.movie_night
3. Display Doorbell / Security Toast on TV Screen¶
Display a notification directly on the TV when a doorbell rings:
alias: "Notify TV on Doorbell"
trigger:
- platform: state
entity_id: binary_sensor.front_doorbell_motion
to: "on"
action:
- service: text.set_value
target:
entity_id: text.lg_tv_screen_notification
data:
value: "Motion detected at front door"
4. A notification with an icon¶
<topicPrefix>/command/notify/<type> shows its text as one of LG's three toasts:
standard(also plainnotify): the toast at the bottom center, text only.advanced: the same toast, with an icon to the left of the text.light: the small toast that slides down at the top right, with a small icon.
webOS 4.4 does not show the advanced toast, so there it is shown as standard, without the icon.



Text opening with an icon name between colons, as :washer: The washing machine is done, shows that icon; the name and the spaces after it are not shown. The icon is a PNG in toast-icons/ in the server's folder on the TV, so washer is /var/lib/tvweb/toast-icons/washer.png. An @ and an absolute path, as :@/usr/palm/notificationmgr/images/alert-notification-icon.png:, uses any image on the TV, such as LG's own. A white glyph of 72 px on a transparent background suits both sizes.
alias: "Washing machine done"
trigger:
- platform: state
entity_id: binary_sensor.washing_machine_running
to: "off"
action:
- action: mqtt.publish
data:
topic: lgtv/command/notify/light
payload: ":washer: The washing machine is done"
5. Switch to an input by its port, whatever it is called¶
Input Source lists inputs by the names given to them in the TV's settings, such as Apple TV (HDMI2), so an automation that selects a name stops working when the input is renamed. Its input_ids attribute maps each option to its port, which stays the same:
alias: "TV to HDMI 2"
trigger:
- platform: state
entity_id: input_boolean.games_night
to: "on"
action:
- service: select.select_option
target:
entity_id: select.lg_tv_input_source
data:
option: >-
{% for name, id in state_attr('select.lg_tv_input_source', 'input_ids').items() if id == 'hdmi2' %}{{ name }}{% endfor %}
6. The weather on Glasshouse Home¶
Glasshouse Home shows the weather next to the clock from what Home Assistant sends it, while the Home tab's Weather setting is From Home Assistant, as it is unless changed. From the internet shows the weather for a place you choose without Home Assistant (Home tab). This sends a weather entity's condition and temperature whenever it changes, every 30 minutes, and when Home Assistant starts. Weather not updated for 3 hours is hidden, and sending an empty value takes it away at once.
alias: "Weather on the TV"
trigger:
- platform: state
entity_id: weather.home
- platform: time_pattern
minutes: "/30"
- platform: homeassistant
event: start
action:
- service: text.set_value
target:
entity_id: text.lg_tv_weather
data:
value: >-
{{ {'condition': states('weather.home'),
'temp': state_attr('weather.home', 'temperature'),
'city': 'Glasgow'} | to_json }}
The temperature is shown as sent, in the unit the weather entity uses. city is optional.
7. Your own lines on Glasshouse Home¶
Glasshouse Home shows up to four lines of your own beside the clock, each an icon, a label and a value. The Home tab's Home Assistant: values at a glance can read them from entities with no automation at all (Home tab); with Sent by an automation chosen there, an automation writes them instead, for text the entities do not have. This sends the next bin collection and the next post delivery whenever one changes and when Home Assistant starts. The list goes straight to the command topic, as text.set_value takes 255 characters at most. They stay until the next push; an empty payload takes them away.
alias: "Lines on Glasshouse Home"
trigger:
- platform: state
entity_id:
- sensor.bin_collection
- sensor.post_delivery
- platform: homeassistant
event: start
action:
- action: mqtt.publish
data:
topic: lgtv/command/homeInfo
payload: >-
{{ [
{'icon': 'mdi:trash-can', 'label': 'Bin',
'value': 'in ' ~ state_attr('sensor.bin_collection', 'days') ~ ' days'},
{'icon': 'mdi:mailbox', 'label': 'Post',
'value': 'in ' ~ states('sensor.post_delivery') ~ ' days'}
] | to_json }}
8. Ask a question on the TV¶
<topicPrefix>/command/ask shows a question over the picture with a button for each answer, chosen with the remote's arrows and OK or with the pointer. Back dismisses it, and it goes away by itself after timeout seconds (30 unless given, at most 600). The question's app is put on the TV the first time one is asked, which takes a few seconds; after that it opens at once. A question with no options gets Yes and No in the TV's language. Like the other commands, it is refused when control is switched off in config.json.
For a yes/no question there is a blueprint that needs no YAML:
Its form asks what puts the question up, the question and its buttons, how long it waits, which phones to ask at the same time, and what to do on Yes, on No and when nobody answers. An answer on a phone takes the question off the TV and the notification off the other phones. Without the button, import https://raw.githubusercontent.com/rorygallagher2024/glasshouse/main/blueprints/automation/glasshouse/ask-on-tv.yaml under Settings → Automations & scenes → Blueprints.
The rest of this section is for writing the automation by hand, for more than two answers or a question that needs more than the form has.
The answer fires event.lg_tv_question_answer: its event type is answer with the chosen option's id in its choice attribute, or dismissed, timeout, replaced (another question came first), closed or failed (the TV would not show it). Its id attribute is the question's, so one automation can tell its own question from another's. Up to four options; without any, the buttons are Yes and No (yes, no). focus picks the option focused at first, counted from 0.
Sending the question's id to <topicPrefix>/command/askClose takes it off the screen, with closed, as when the same question was answered in a phone notification. An empty payload closes whichever question is up.
alias: "Cinema lights?"
trigger:
- platform: state
entity_id: media_player.formuler
to: playing
action:
- action: mqtt.publish
data:
topic: lgtv/command/ask
payload: >-
{{ {'id': 'cinema', 'title': 'Cinema mode?', 'message': 'Dim the lights by the TV',
'options': [{'id': 'yes', 'label': 'Yes'}, {'id': 'no', 'label': 'No'}],
'timeout': 25} | to_json }}
- wait_for_trigger:
- trigger: state
entity_id: event.lg_tv_question_answer
attribute: event_type
timeout: "00:00:35"
- condition: template
value_template: >-
{{ wait.trigger is not none and wait.trigger.to_state.attributes.id == 'cinema'
and wait.trigger.to_state.attributes.choice == 'yes' }}
- action: scene.turn_on
target:
entity_id: scene.cinema
9. A board on Glasshouse Home¶
With the Home tab's Home Assistant: board set to Sent by an automation, an automation can put a titled list of up to twenty lines beside the lines, shown four at a time, such as today's matches. Glasshouse fetches nothing for it: the lines come from whatever integration you choose, and its terms are between you and it. With minutes, the board goes that long after the last push, so results that stop coming are not left up; an empty payload takes it away at once. It is not kept across a restart.
This sends the matches of the teams followed with Team Tracker whenever one of them changes:
alias: "Board on Glasshouse Home"
trigger:
- platform: state
entity_id:
- sensor.team_tracker_malmo
- sensor.team_tracker_arsenal
action:
- action: mqtt.publish
data:
topic: lgtv/command/homeBoard
payload: >-
{% set ns = namespace(lines=[]) %}
{% for s in ['sensor.team_tracker_malmo', 'sensor.team_tracker_arsenal'] %}
{% set a = states[s].attributes %}
{% if states(s) in ['PRE', 'IN', 'POST'] %}
{% set score = a.team_score ~ '–' ~ a.opponent_score if states(s) != 'PRE' else '–' %}
{% set ns.lines = ns.lines + [{'label': a.team_name ~ ' ' ~ score ~ ' ' ~ a.opponent_name,
'value': a.clock if states(s) == 'IN' else (a.kickoff_in or '')}] %}
{% endif %}
{% endfor %}
{{ {'title': 'Football today', 'minutes': 30, 'lines': ns.lines} | to_json }}
Universal Media Player Setup¶
Home Assistant's own MQTT discovery has no media_player platform, so Glasshouse cannot create one through discovery alone. Two ways to still get one media control card:
Through a separate integration¶
With grzegorz914/homeassistant-mqtt-media-player (v0.10.3 or newer) installed through HACS, turning on Media player under Published TV entities on the dashboard's MQTT tab (universalMediaPlayer under mqtt in config.json) publishes one real media_player entity: power, volume, mute, sound output, play/pause/stop/skip, the current app or input's icon as the card's cover (through the icon server, so iconServer needs to be on too), and a media browser of the TV's inputs and installed apps with the same icons. Save & restart applies it, and a change made in config.json needs the server restarted.
Where Internet TV has a lineup, IPTV is one of the card's sources, and picking it opens Internet TV's guide on Glasshouse Home. A channel is picked in the media browser.
While the TV is off, in Active Standby or asleep, the card shows off with only power left, at the moment Power reads off. Switching it on sends a Wake-on-LAN packet to the TV's MAC address, which Glasshouse gives the integration once it knows it, so the TV needs Wake-on-LAN or Wake on Wi-Fi turned on.
Through Home Assistant's own universal media player¶
Home Assistant's universal media player puts the discovered power, volume, mute, playback and input controls together in one, for a media control card on a dashboard, with no other integration to install. It takes a title only from another media player, so it shows none. Play and pause are sent as the remote's Play and Pause keys, so they work only in apps that act on those keys: the TV's own player does, and the Jellyfin app resumes with Play but ignores Pause.
Add the following to configuration.yaml. Power uses the LG TV switch from Switched off, and back on. The entity IDs start with the TV's device.id: for one set to lg_c9, select.lg_tv_input_source is select.lg_c9_input_source.
media_player:
- platform: universal
name: "LG OLED TV"
unique_id: lg_oled_tv_media_player
children: []
commands:
turn_on:
action: switch.turn_on
target:
entity_id: switch.lg_tv
turn_off:
action: switch.turn_off
target:
entity_id: switch.lg_tv
volume_up:
action: mqtt.publish
data:
topic: "lgtv/command/volume"
payload: "+1"
volume_down:
action: mqtt.publish
data:
topic: "lgtv/command/volume"
payload: "-1"
volume_set:
action: number.set_value
target:
entity_id: number.lg_tv_volume
data:
# Home Assistant passes the level from 0 to 1 as volume_level.
value: "{{ (volume_level * 100) | round | int }}"
volume_mute:
action: switch.toggle
target:
entity_id: switch.lg_tv_mute
media_play:
action: button.press
target:
entity_id: button.lg_tv_play
media_pause:
action: button.press
target:
entity_id: button.lg_tv_pause
media_play_pause:
action: button.press
target:
entity_id: button.lg_tv_play_pause
media_stop:
action: button.press
target:
entity_id: button.lg_tv_stop
select_source:
action: select.select_option
target:
entity_id: select.lg_tv_input_source
data:
option: "{{ source }}"
state_template: >-
{% if not is_state('switch.lg_tv', 'on') %}off
{% elif states('sensor.lg_tv_play_state') in ['playing', 'paused'] %}{{ states('sensor.lg_tv_play_state') }}
{% else %}on{% endif %}
attributes:
is_volume_muted: switch.lg_tv_mute
volume_level: number.lg_tv_volume|volume_level
source: select.lg_tv_input_source
source_list: select.lg_tv_input_source|options
Switched off, and back on¶
When the TV is switched off, its entities stay available and show a switched-off TV: Power reads off, readings of what is on screen (active app, player state, video signal, HDMI details) read Off, and settings that still hold, such as picture mode and volume, keep theirs. While the TV is still up in Active Standby (with Stay connected when off on, or during panel compensation), live measurements such as SoC temperature keep reporting, once a minute rather than every 10 seconds, and controls keep working. With Stay connected when off, it still sleeps for five hours every night (01:00 to 06:00 unless moved under Advanced → Nightly power-down). Once it is asleep in standby, both are greyed out: a measurement would be stale, and nothing on the TV could act on a control. Everything, Power included, goes unavailable if the server stops while the TV is on, and so it does for a TV that goes from Active straight to Suspend, as an LCD does: it is asleep within milliseconds, too soon to tell the broker, so Home Assistant learns of it once the connection has been silent for about 15 seconds.
A TV in standby is asleep and cannot receive commands, so it is switched back on over the network with Wake-on-LAN.
- Turn on Wake-on-LAN on the TV: in the web dashboard under System → Power, on the TV dashboard under System → Power, or in LG's menu under Settings → General → Mobile TV On. Wake-on-LAN works over Ethernet and, on most models, Wi-Fi.
- In Home Assistant, add the Wake on LAN integration (Settings → Devices & services → Add integration → Wake on LAN) with the TV's MAC address. The address is listed under Connections on the TV's device page in Home Assistant, and as the MAC Address sensor. A TV has one MAC address for Ethernet and another for Wi-Fi: use the one Glasshouse lists, which is the connection in use. As the broadcast address, give the network's (
192.168.1.255on a192.168.1.xnetwork), not the TV's own: a TV asleep does not answer at its address, so a packet sent there never leaves Home Assistant.
This creates a button that wakes the TV from standby. To make one switch that shows whether the TV is on and turns it on or off, add a template switch to configuration.yaml, with the TV's MAC address. If it already has a template: key, add the switch: entry under it:
template:
- switch:
- name: "LG TV"
unique_id: lg_tv_power_switch
icon: mdi:television
state: "{{ is_state('binary_sensor.lg_tv_power', 'on') }}"
turn_on:
# Wakes a TV that is asleep in standby.
- action: wake_on_lan.send_magic_packet
data:
mac: "AA:BB:CC:DD:EE:FF"
# Wakes a TV that is still up in Active Standby, which ignores the
# packet above. Unavailable while the TV is asleep, hence the
# continue_on_error.
- action: button.press
continue_on_error: true
target:
entity_id: button.lg_tv_power_on
turn_off:
- action: button.press
target:
entity_id: button.lg_tv_power_off
The wake_on_lan.send_magic_packet action needs wake_on_lan: in configuration.yaml if the integration was not added through the UI. Entity IDs start with the device name, lg_tv by default; a TV with its own name in config.json uses that instead.
Hue Sync also discovers supported sync settings: brightness, intensity, Video/Game mode, entertainment area, per-mode background light, automatic start and automatic-start notifications. Controls share retained JSON settings state and use separate command topics. The existing streaming entity and topics are preserved.