[{"data":1,"prerenderedAt":1191},["ShallowReactive",2],{"\u002Fposts\u002Fcontrol-lg-webos-tv-with-apple-remote-home-assistant":3},{"id":4,"title":5,"author":6,"body":7,"categories":1171,"date":1174,"description":1175,"extension":1176,"image":1177,"lang":1178,"meta":1179,"navigation":1180,"path":1181,"seo":1182,"stem":1183,"tags":1184,"type":1189,"__hash__":1190},"content\u002Fposts\u002F35.control-lg-webos-tv-with-apple-remote-home-assistant.md","Control an LG webOS TV with the Apple Remote App through Home Assistant","hanlee",{"type":8,"value":9,"toc":1161},"minimark",[10,14,30,33,58,61,64,69,72,84,101,109,153,156,188,191,193,197,200,249,252,266,277,279,283,289,622,629,705,708,718,721,740,743,745,749,752,905,908,925,928,930,934,937,940,957,965,968,971,1007,1010,1013,1015,1019,1022,1027,1110,1113,1115,1119,1122,1136,1142,1144,1148,1151,1154,1157],[11,12,13],"p",{},"I have an LG webOS TV in Home Assistant, and I wanted one small quality-of-life improvement: control it from the Apple Remote interface on my iPhone.",[11,15,16,17,24,25,29],{},"This setup was inspired by the Home Assistant Community post ",[18,19,23],"a",{"href":20,"rel":21},"https:\u002F\u002Fcommunity.home-assistant.io\u002Ft\u002Fcontrol-android-tv-via-homekit-remote-app-using-home-assistant\u002F929880",[22],"nofollow","Control Android TV via HomeKit Remote App using Home Assistant",". I adapted the same event-driven idea for LG webOS and the ",[26,27,28],"code",{},"webostv.button"," action.",[11,31,32],{},"The idea is simple:",[34,35,36,40,47,50,53],"ol",{},[37,38,39],"li",{},"Home Assistant exposes the TV to Apple Home via HomeKit.",[37,41,42,43,46],{},"The iPhone Apple Remote sends ",[26,44,45],{},"homekit_tv_remote_key_pressed"," events to Home Assistant.",[37,48,49],{},"A Home Assistant automation catches those events.",[37,51,52],{},"A script translates HomeKit key names into LG webOS button commands.",[37,54,55,56,29],{},"Home Assistant sends the command to the TV through the ",[26,57,28],{},[11,59,60],{},"This makes the iPhone remote behave like a lightweight LG TV remote, without needing to open the LG app.",[62,63],"hr",{},[65,66,68],"h2",{"id":67},"requirements","Requirements",[11,70,71],{},"Before setting this up, make sure you already have:",[73,74,75,78,81],"ul",{},[37,76,77],{},"Home Assistant running",[37,79,80],{},"LG webOS TV added to Home Assistant",[37,82,83],{},"A working media player entity, for example:",[85,86,91],"pre",{"className":87,"code":88,"language":89,"meta":90,"style":90},"language-yaml shiki shiki-themes vitesse-dark vitesse-light vitesse-light","media_player.lg_tv\n","yaml","",[26,92,93],{"__ignoreMap":90},[94,95,98],"span",{"class":96,"line":97},"line",1,[94,99,88],{"class":100},"sH1aP",[73,102,103,106],{},[37,104,105],{},"HomeKit Bridge configured in Home Assistant",[37,107,108],{},"The TV exposed to Apple Home",[110,111,112],"blockquote",{},[11,113,114,118,119,122,123,128,129,132,133,136,137,140,141,144,145,148,149,152],{},[115,116,117],"strong",{},"Important:"," expose the TV as its own HomeKit Bridge instance in ",[115,120,121],{},"Accessory mode",". According to the ",[18,124,127],{"href":125,"rel":126},"https:\u002F\u002Fwww.home-assistant.io\u002Fintegrations\u002Fhomekit\u002F",[22],"Home Assistant HomeKit Bridge documentation",", Television media players (",[26,130,131],{},"media_player"," entities with device class ",[26,134,135],{},"tv"," or ",[26,138,139],{},"receiver",") must use ",[26,142,143],{},"accessory"," mode instead of the default ",[26,146,147],{},"bridge"," mode. The include filter should contain only that single TV entity, for example ",[26,150,151],{},"media_player.lg_tv",".",[11,154,155],{},"In practice, this means I do not put the LG TV inside my normal HomeKit Bridge with lights, switches, and sensors. I create a separate HomeKit Bridge entry just for the TV:",[34,157,158,168,175,180,185],{},[37,159,160,161,164,165,152],{},"Go to ",[115,162,163],{},"Settings"," → ",[115,166,167],{},"Devices & services",[37,169,170,171,174],{},"Add another ",[115,172,173],{},"HomeKit Bridge"," integration.",[37,176,177,178,152],{},"Choose ",[115,179,121],{},[37,181,182,183,152],{},"Include only ",[26,184,151],{},[37,186,187],{},"Pair that new HomeKit accessory in the Apple Home app.",[11,189,190],{},"Once the TV appears in Apple Home as its own accessory, iOS can send remote key events back into Home Assistant.",[62,192],{},[65,194,196],{"id":195},"how-the-flow-works","How the Flow Works",[11,198,199],{},"When I press a button in the Apple Remote app, Home Assistant receives an event like this:",[85,201,203],{"className":87,"code":202,"language":89,"meta":90,"style":90},"event_type: homekit_tv_remote_key_pressed\nevent_data:\n  entity_id: media_player.lg_tv\n  key_name: arrow_right\n",[26,204,205,218,227,238],{"__ignoreMap":90},[94,206,207,211,215],{"class":96,"line":97},[94,208,210],{"class":209},"sgvEi","event_type",[94,212,214],{"class":213},"sNwAI",":",[94,216,217],{"class":100}," homekit_tv_remote_key_pressed\n",[94,219,221,224],{"class":96,"line":220},2,[94,222,223],{"class":209},"event_data",[94,225,226],{"class":213},":\n",[94,228,230,233,235],{"class":96,"line":229},3,[94,231,232],{"class":209},"  entity_id",[94,234,214],{"class":213},[94,236,237],{"class":100}," media_player.lg_tv\n",[94,239,241,244,246],{"class":96,"line":240},4,[94,242,243],{"class":209},"  key_name",[94,245,214],{"class":213},[94,247,248],{"class":100}," arrow_right\n",[11,250,251],{},"The important fields are:",[73,253,254,260],{},[37,255,256,259],{},[26,257,258],{},"entity_id",": which HomeKit TV accessory received the remote command",[37,261,262,265],{},[26,263,264],{},"key_name",": which key was pressed",[11,267,268,269,272,273,276],{},"Home Assistant does not automatically know that ",[26,270,271],{},"arrow_right"," should become an LG webOS ",[26,274,275],{},"RIGHT"," button command. That translation is what the script handles.",[62,278],{},[65,280,282],{"id":281},"script-translate-homekit-keys-to-lg-webos-buttons","Script: Translate HomeKit Keys to LG webOS Buttons",[11,284,285,286,214],{},"Create a Home Assistant script named ",[26,287,288],{},"LG TV Remote Handler",[85,290,292],{"className":87,"code":291,"language":89,"meta":90,"style":90},"alias: LG TV Remote Handler\ndescription: Controlling LG webOS TV via HomeKit Remote\nmode: parallel\nfields:\n  media_player_entity:\n    description: Entity ID of the LG TV media player\n    example: media_player.lg_tv\n  key_name:\n    description: Key pressed on HomeKit Remote\n    example: arrow_right\nsequence:\n  - variables:\n      command_map:\n        arrow_up: UP\n        arrow_down: DOWN\n        arrow_left: LEFT\n        arrow_right: RIGHT\n        select: ENTER\n        back: BACK\n        information: HOME\n        play_pause: PLAY\n  - condition: template\n    value_template: |-\n      {{\n        media_player_entity is defined\n        and key_name is defined\n        and key_name in command_map\n      }}\n  - action: webostv.button\n    target:\n      entity_id: \"{{ media_player_entity }}\"\n    data:\n      button: \"{{ command_map[key_name] }}\"\n",[26,293,294,304,314,324,331,339,350,360,367,377,386,394,405,413,424,435,446,457,468,479,490,501,514,530,536,542,548,554,560,573,581,599,607],{"__ignoreMap":90},[94,295,296,299,301],{"class":96,"line":97},[94,297,298],{"class":209},"alias",[94,300,214],{"class":213},[94,302,303],{"class":100}," LG TV Remote Handler\n",[94,305,306,309,311],{"class":96,"line":220},[94,307,308],{"class":209},"description",[94,310,214],{"class":213},[94,312,313],{"class":100}," Controlling LG webOS TV via HomeKit Remote\n",[94,315,316,319,321],{"class":96,"line":229},[94,317,318],{"class":209},"mode",[94,320,214],{"class":213},[94,322,323],{"class":100}," parallel\n",[94,325,326,329],{"class":96,"line":240},[94,327,328],{"class":209},"fields",[94,330,226],{"class":213},[94,332,334,337],{"class":96,"line":333},5,[94,335,336],{"class":209},"  media_player_entity",[94,338,226],{"class":213},[94,340,342,345,347],{"class":96,"line":341},6,[94,343,344],{"class":209},"    description",[94,346,214],{"class":213},[94,348,349],{"class":100}," Entity ID of the LG TV media player\n",[94,351,353,356,358],{"class":96,"line":352},7,[94,354,355],{"class":209},"    example",[94,357,214],{"class":213},[94,359,237],{"class":100},[94,361,363,365],{"class":96,"line":362},8,[94,364,243],{"class":209},[94,366,226],{"class":213},[94,368,370,372,374],{"class":96,"line":369},9,[94,371,344],{"class":209},[94,373,214],{"class":213},[94,375,376],{"class":100}," Key pressed on HomeKit Remote\n",[94,378,380,382,384],{"class":96,"line":379},10,[94,381,355],{"class":209},[94,383,214],{"class":213},[94,385,248],{"class":100},[94,387,389,392],{"class":96,"line":388},11,[94,390,391],{"class":209},"sequence",[94,393,226],{"class":213},[94,395,397,400,403],{"class":96,"line":396},12,[94,398,399],{"class":213},"  -",[94,401,402],{"class":209}," variables",[94,404,226],{"class":213},[94,406,408,411],{"class":96,"line":407},13,[94,409,410],{"class":209},"      command_map",[94,412,226],{"class":213},[94,414,416,419,421],{"class":96,"line":415},14,[94,417,418],{"class":209},"        arrow_up",[94,420,214],{"class":213},[94,422,423],{"class":100}," UP\n",[94,425,427,430,432],{"class":96,"line":426},15,[94,428,429],{"class":209},"        arrow_down",[94,431,214],{"class":213},[94,433,434],{"class":100}," DOWN\n",[94,436,438,441,443],{"class":96,"line":437},16,[94,439,440],{"class":209},"        arrow_left",[94,442,214],{"class":213},[94,444,445],{"class":100}," LEFT\n",[94,447,449,452,454],{"class":96,"line":448},17,[94,450,451],{"class":209},"        arrow_right",[94,453,214],{"class":213},[94,455,456],{"class":100}," RIGHT\n",[94,458,460,463,465],{"class":96,"line":459},18,[94,461,462],{"class":209},"        select",[94,464,214],{"class":213},[94,466,467],{"class":100}," ENTER\n",[94,469,471,474,476],{"class":96,"line":470},19,[94,472,473],{"class":209},"        back",[94,475,214],{"class":213},[94,477,478],{"class":100}," BACK\n",[94,480,482,485,487],{"class":96,"line":481},20,[94,483,484],{"class":209},"        information",[94,486,214],{"class":213},[94,488,489],{"class":100}," HOME\n",[94,491,493,496,498],{"class":96,"line":492},21,[94,494,495],{"class":209},"        play_pause",[94,497,214],{"class":213},[94,499,500],{"class":100}," PLAY\n",[94,502,504,506,509,511],{"class":96,"line":503},22,[94,505,399],{"class":213},[94,507,508],{"class":209}," condition",[94,510,214],{"class":213},[94,512,513],{"class":100}," template\n",[94,515,517,520,522,526],{"class":96,"line":516},23,[94,518,519],{"class":209},"    value_template",[94,521,214],{"class":213},[94,523,525],{"class":524},"sqwTx"," |",[94,527,529],{"class":528},"sO4lr","-\n",[94,531,533],{"class":96,"line":532},24,[94,534,535],{"class":100},"      {{\n",[94,537,539],{"class":96,"line":538},25,[94,540,541],{"class":100},"        media_player_entity is defined\n",[94,543,545],{"class":96,"line":544},26,[94,546,547],{"class":100},"        and key_name is defined\n",[94,549,551],{"class":96,"line":550},27,[94,552,553],{"class":100},"        and key_name in command_map\n",[94,555,557],{"class":96,"line":556},28,[94,558,559],{"class":100},"      }}\n",[94,561,563,565,568,570],{"class":96,"line":562},29,[94,564,399],{"class":213},[94,566,567],{"class":209}," action",[94,569,214],{"class":213},[94,571,572],{"class":100}," webostv.button\n",[94,574,576,579],{"class":96,"line":575},30,[94,577,578],{"class":209},"    target",[94,580,226],{"class":213},[94,582,584,587,589,593,596],{"class":96,"line":583},31,[94,585,586],{"class":209},"      entity_id",[94,588,214],{"class":213},[94,590,592],{"class":591},"s6Hc8"," \"",[94,594,595],{"class":100},"{{ media_player_entity }}",[94,597,598],{"class":591},"\"\n",[94,600,602,605],{"class":96,"line":601},32,[94,603,604],{"class":209},"    data",[94,606,226],{"class":213},[94,608,610,613,615,617,620],{"class":96,"line":609},33,[94,611,612],{"class":209},"      button",[94,614,214],{"class":213},[94,616,592],{"class":591},[94,618,619],{"class":100},"{{ command_map[key_name] }}",[94,621,598],{"class":591},[11,623,624,625,628],{},"The ",[26,626,627],{},"command_map"," is the key part:",[85,630,632],{"className":87,"code":631,"language":89,"meta":90,"style":90},"arrow_up: UP\narrow_down: DOWN\narrow_left: LEFT\narrow_right: RIGHT\nselect: ENTER\nback: BACK\ninformation: HOME\nplay_pause: PLAY\n",[26,633,634,643,652,661,669,678,687,696],{"__ignoreMap":90},[94,635,636,639,641],{"class":96,"line":97},[94,637,638],{"class":209},"arrow_up",[94,640,214],{"class":213},[94,642,423],{"class":100},[94,644,645,648,650],{"class":96,"line":220},[94,646,647],{"class":209},"arrow_down",[94,649,214],{"class":213},[94,651,434],{"class":100},[94,653,654,657,659],{"class":96,"line":229},[94,655,656],{"class":209},"arrow_left",[94,658,214],{"class":213},[94,660,445],{"class":100},[94,662,663,665,667],{"class":96,"line":240},[94,664,271],{"class":209},[94,666,214],{"class":213},[94,668,456],{"class":100},[94,670,671,674,676],{"class":96,"line":333},[94,672,673],{"class":209},"select",[94,675,214],{"class":213},[94,677,467],{"class":100},[94,679,680,683,685],{"class":96,"line":341},[94,681,682],{"class":209},"back",[94,684,214],{"class":213},[94,686,478],{"class":100},[94,688,689,692,694],{"class":96,"line":352},[94,690,691],{"class":209},"information",[94,693,214],{"class":213},[94,695,489],{"class":100},[94,697,698,701,703],{"class":96,"line":362},[94,699,700],{"class":209},"play_pause",[94,702,214],{"class":213},[94,704,500],{"class":100},[11,706,707],{},"The left side is the HomeKit key name. The right side is the LG webOS button name.",[11,709,710,711,713,714,717],{},"I map ",[26,712,691],{}," to ",[26,715,716],{},"HOME"," because that button is convenient as a Home shortcut on the Apple Remote interface. You can change this mapping if you prefer another behavior.",[11,719,720],{},"The script also checks that:",[73,722,723,729,733],{},[37,724,725,728],{},[26,726,727],{},"media_player_entity"," exists",[37,730,731,728],{},[26,732,264],{},[37,734,735,737,738],{},[26,736,264],{}," is supported by ",[26,739,627],{},[11,741,742],{},"If an unknown key is received, the script simply stops without sending anything to the TV.",[62,744],{},[65,746,748],{"id":747},"automation-listen-for-apple-remote-events","Automation: Listen for Apple Remote Events",[11,750,751],{},"Next, create an automation that listens for HomeKit remote key events:",[85,753,755],{"className":87,"code":754,"language":89,"meta":90,"style":90},"alias: Handle Any HomeKit Remote\ndescription: Listen to HomeKit remote events and control LG webOS TVs\ntriggers:\n  - event_type: homekit_tv_remote_key_pressed\n    trigger: event\nconditions:\n  - condition: template\n    value_template: |-\n      {{\n        trigger.event.data.entity_id is defined\n        and trigger.event.data.entity_id == 'media_player.lg_tv'\n      }}\nactions:\n  - data:\n      media_player_entity: media_player.lg_tv\n      key_name: \"{{ trigger.event.data.key_name }}\"\n    action: script.lg_tv_remote_handler\nmode: parallel\n",[26,756,757,766,775,782,793,803,810,820,830,834,839,844,848,855,864,873,887,897],{"__ignoreMap":90},[94,758,759,761,763],{"class":96,"line":97},[94,760,298],{"class":209},[94,762,214],{"class":213},[94,764,765],{"class":100}," Handle Any HomeKit Remote\n",[94,767,768,770,772],{"class":96,"line":220},[94,769,308],{"class":209},[94,771,214],{"class":213},[94,773,774],{"class":100}," Listen to HomeKit remote events and control LG webOS TVs\n",[94,776,777,780],{"class":96,"line":229},[94,778,779],{"class":209},"triggers",[94,781,226],{"class":213},[94,783,784,786,789,791],{"class":96,"line":240},[94,785,399],{"class":213},[94,787,788],{"class":209}," event_type",[94,790,214],{"class":213},[94,792,217],{"class":100},[94,794,795,798,800],{"class":96,"line":333},[94,796,797],{"class":209},"    trigger",[94,799,214],{"class":213},[94,801,802],{"class":100}," event\n",[94,804,805,808],{"class":96,"line":341},[94,806,807],{"class":209},"conditions",[94,809,226],{"class":213},[94,811,812,814,816,818],{"class":96,"line":352},[94,813,399],{"class":213},[94,815,508],{"class":209},[94,817,214],{"class":213},[94,819,513],{"class":100},[94,821,822,824,826,828],{"class":96,"line":362},[94,823,519],{"class":209},[94,825,214],{"class":213},[94,827,525],{"class":524},[94,829,529],{"class":528},[94,831,832],{"class":96,"line":369},[94,833,535],{"class":100},[94,835,836],{"class":96,"line":379},[94,837,838],{"class":100},"        trigger.event.data.entity_id is defined\n",[94,840,841],{"class":96,"line":388},[94,842,843],{"class":100},"        and trigger.event.data.entity_id == 'media_player.lg_tv'\n",[94,845,846],{"class":96,"line":396},[94,847,559],{"class":100},[94,849,850,853],{"class":96,"line":407},[94,851,852],{"class":209},"actions",[94,854,226],{"class":213},[94,856,857,859,862],{"class":96,"line":415},[94,858,399],{"class":213},[94,860,861],{"class":209}," data",[94,863,226],{"class":213},[94,865,866,869,871],{"class":96,"line":426},[94,867,868],{"class":209},"      media_player_entity",[94,870,214],{"class":213},[94,872,237],{"class":100},[94,874,875,878,880,882,885],{"class":96,"line":437},[94,876,877],{"class":209},"      key_name",[94,879,214],{"class":213},[94,881,592],{"class":591},[94,883,884],{"class":100},"{{ trigger.event.data.key_name }}",[94,886,598],{"class":591},[94,888,889,892,894],{"class":96,"line":448},[94,890,891],{"class":209},"    action",[94,893,214],{"class":213},[94,895,896],{"class":100}," script.lg_tv_remote_handler\n",[94,898,899,901,903],{"class":96,"line":459},[94,900,318],{"class":209},[94,902,214],{"class":213},[94,904,323],{"class":100},[11,906,907],{},"This automation does three things:",[34,909,910,916,922],{},[37,911,912,913,915],{},"Listens for every ",[26,914,45],{}," event.",[37,917,918,919,921],{},"Filters events so only ",[26,920,151],{}," is handled.",[37,923,924],{},"Calls the script with the pressed key name.",[11,926,927],{},"The condition is important if you expose more than one TV to HomeKit. Without it, one remote event could accidentally control the wrong TV.",[62,929],{},[65,931,933],{"id":932},"testing-the-event","Testing the Event",[11,935,936],{},"If the remote does not work immediately, first check whether Home Assistant receives the event.",[11,938,939],{},"In Home Assistant:",[34,941,942,947,954],{},[37,943,160,944,152],{},[115,945,946],{},"Developer Tools",[37,948,949,950,953],{},"Open the ",[115,951,952],{},"Events"," tab.",[37,955,956],{},"Start listening to:",[85,958,963],{"className":959,"code":961,"language":962,"meta":90},[960],"language-text","homekit_tv_remote_key_pressed\n","text",[26,964,961],{"__ignoreMap":90},[11,966,967],{},"Then open the Apple Remote app on your iPhone and press the arrow keys.",[11,969,970],{},"You should see event data similar to:",[85,972,974],{"className":87,"code":973,"language":89,"meta":90,"style":90},"event_type: homekit_tv_remote_key_pressed\ndata:\n  entity_id: media_player.lg_tv\n  key_name: arrow_right\n",[26,975,976,984,991,999],{"__ignoreMap":90},[94,977,978,980,982],{"class":96,"line":97},[94,979,210],{"class":209},[94,981,214],{"class":213},[94,983,217],{"class":100},[94,985,986,989],{"class":96,"line":220},[94,987,988],{"class":209},"data",[94,990,226],{"class":213},[94,992,993,995,997],{"class":96,"line":229},[94,994,232],{"class":209},[94,996,214],{"class":213},[94,998,237],{"class":100},[94,1000,1001,1003,1005],{"class":96,"line":240},[94,1002,243],{"class":209},[94,1004,214],{"class":213},[94,1006,248],{"class":100},[11,1008,1009],{},"If the event appears, HomeKit is working and the problem is probably in the script or automation mapping.",[11,1011,1012],{},"If no event appears, check that the TV is exposed through HomeKit Bridge and visible in Apple Home.",[62,1014],{},[65,1016,1018],{"id":1017},"extending-the-button-mapping","Extending the Button Mapping",[11,1020,1021],{},"The setup is intentionally small, but it is easy to extend.",[11,1023,1024,1025,214],{},"For example, if you find more HomeKit key names from the event listener, you can add them to ",[26,1026,627],{},[85,1028,1030],{"className":87,"code":1029,"language":89,"meta":90,"style":90},"command_map:\n  arrow_up: UP\n  arrow_down: DOWN\n  arrow_left: LEFT\n  arrow_right: RIGHT\n  select: ENTER\n  back: BACK\n  information: HOME\n  play_pause: PLAY\n",[26,1031,1032,1038,1047,1056,1065,1074,1083,1092,1101],{"__ignoreMap":90},[94,1033,1034,1036],{"class":96,"line":97},[94,1035,627],{"class":209},[94,1037,226],{"class":213},[94,1039,1040,1043,1045],{"class":96,"line":220},[94,1041,1042],{"class":209},"  arrow_up",[94,1044,214],{"class":213},[94,1046,423],{"class":100},[94,1048,1049,1052,1054],{"class":96,"line":229},[94,1050,1051],{"class":209},"  arrow_down",[94,1053,214],{"class":213},[94,1055,434],{"class":100},[94,1057,1058,1061,1063],{"class":96,"line":240},[94,1059,1060],{"class":209},"  arrow_left",[94,1062,214],{"class":213},[94,1064,445],{"class":100},[94,1066,1067,1070,1072],{"class":96,"line":333},[94,1068,1069],{"class":209},"  arrow_right",[94,1071,214],{"class":213},[94,1073,456],{"class":100},[94,1075,1076,1079,1081],{"class":96,"line":341},[94,1077,1078],{"class":209},"  select",[94,1080,214],{"class":213},[94,1082,467],{"class":100},[94,1084,1085,1088,1090],{"class":96,"line":352},[94,1086,1087],{"class":209},"  back",[94,1089,214],{"class":213},[94,1091,478],{"class":100},[94,1093,1094,1097,1099],{"class":96,"line":362},[94,1095,1096],{"class":209},"  information",[94,1098,214],{"class":213},[94,1100,489],{"class":100},[94,1102,1103,1106,1108],{"class":96,"line":369},[94,1104,1105],{"class":209},"  play_pause",[94,1107,214],{"class":213},[94,1109,500],{"class":100},[11,1111,1112],{},"The same automation can stay unchanged. Only the script needs to know how to translate keys.",[62,1114],{},[65,1116,1118],{"id":1117},"why-use-a-separate-script","Why Use a Separate Script?",[11,1120,1121],{},"I keep the translation logic in a script instead of putting everything directly in the automation for a few reasons:",[73,1123,1124,1127,1130,1133],{},[37,1125,1126],{},"The automation only handles event filtering.",[37,1128,1129],{},"The script owns the key-to-button mapping.",[37,1131,1132],{},"It is easier to reuse for another LG TV later.",[37,1134,1135],{},"It keeps the YAML easier to read.",[11,1137,1138,1139,1141],{},"For multiple TVs, the script can stay generic because it accepts ",[26,1140,727],{}," as a field. Each automation can pass a different TV entity.",[62,1143],{},[65,1145,1147],{"id":1146},"final-thoughts","Final Thoughts",[11,1149,1150],{},"This is a small Home Assistant automation, but it makes the LG TV feel much better integrated with the Apple ecosystem.",[11,1152,1153],{},"Instead of switching to the LG remote app, I can open the Apple Remote from Control Center and navigate the TV with familiar buttons. Home Assistant sits in the middle and translates everything into LG webOS commands.",[11,1155,1156],{},"It is also a nice example of why Home Assistant is so useful: it can connect two ecosystems that were not designed to talk to each other directly and make the result feel native.",[1158,1159,1160],"style",{},"html pre.shiki code .sH1aP, html code.shiki .sH1aP{--shiki-dark:#C98A7D;--shiki-light:#B56959;--shiki-default:#B56959}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sgvEi, html code.shiki .sgvEi{--shiki-dark:#B8A965;--shiki-light:#998418;--shiki-default:#998418}html pre.shiki code .sNwAI, html code.shiki .sNwAI{--shiki-dark:#666666;--shiki-light:#999999;--shiki-default:#999999}html pre.shiki code .sqwTx, html code.shiki .sqwTx{--shiki-dark:#4D9375;--shiki-light:#1E754F;--shiki-default:#1E754F}html pre.shiki code .sO4lr, html code.shiki .sO4lr{--shiki-dark:#CB7676;--shiki-light:#AB5959;--shiki-default:#AB5959}html pre.shiki code .s6Hc8, html code.shiki .s6Hc8{--shiki-dark:#C98A7D77;--shiki-light:#B5695977;--shiki-default:#B5695977}",{"title":90,"searchDepth":220,"depth":220,"links":1162},[1163,1164,1165,1166,1167,1168,1169,1170],{"id":67,"depth":220,"text":68},{"id":195,"depth":220,"text":196},{"id":281,"depth":220,"text":282},{"id":747,"depth":220,"text":748},{"id":932,"depth":220,"text":933},{"id":1017,"depth":220,"text":1018},{"id":1117,"depth":220,"text":1118},{"id":1146,"depth":220,"text":1147},[1172,1173],"Home Automation","Home Assistant","2026-06-03","How I use Home Assistant to translate Apple HomeKit remote key events into LG webOS TV button commands.","md","\u002Fimages\u002F2026\u002Flg-webos-apple-remote-home-assistant.png","en-US",{},true,"\u002Fposts\u002Fcontrol-lg-webos-tv-with-apple-remote-home-assistant",{"title":5,"description":1175},"posts\u002F35.control-lg-webos-tv-with-apple-remote-home-assistant",[1173,1185,1186,1187,1188],"HomeKit","Apple Remote","LG webOS","Smart TV","post","kYViUS5HAjF1jxKUixY1oGHqhLpEKHizH76vkTe6J_w",1780513118224]