# griches/lgtvremote-cli architecture

> Architecture diagram of the GitHub repository griches/lgtvremote-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/griches/lgtvremote-cli
- Repository: https://github.com/griches/lgtvremote-cli

## Overview

LG TV Remote CLI is a standard-library Python command-line client for controlling webOS TVs over SSAP/WebSocket and Wake-on-LAN. The main workflow discovers or adds a TV, pairs it, saves device details, then routes commands to the selected TV. The README documents additional control areas and integrations, but the implementation is a single 110 KB module; the graph separates its documented responsibilities rather than implying separate packages. Edges use README-documented behavior or the excerpted dispatcher; unsampled command internals are not independently verified.

Main entry points: [`lgtvremote_cli.py`](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py) (Command dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and devices"]
  node_entry["Command dispatcher<br/>[lgtvremote_cli.py]"]
  node_discovery["TV discovery<br/>[lgtvremote_cli.py]"]
  node_device_mgmt["Device management<br/>[lgtvremote_cli.py]"]
  node_config[("Device configuration<br/>[lgtvremote_cli.py]")]
end

subgraph group_connection["Connection and pairing"]
  node_pairing["PIN pairing<br/>[lgtvremote_cli.py]"]
  node_ssap["SSAP WebSocket<br/>[lgtvremote_cli.py]"]
end

subgraph group_controls["TV controls"]
  node_power["Power control<br/>[lgtvremote_cli.py]"]
  node_remote["Remote and media<br/>[lgtvremote_cli.py]"]
  node_volume["Audio control<br/>[lgtvremote_cli.py]"]
  node_inputs["Inputs and channels<br/>[lgtvremote_cli.py]"]
  node_apps["Apps and URLs<br/>[lgtvremote_cli.py]"]
  node_display["Display settings<br/>[lgtvremote_cli.py]"]
end

subgraph group_integrations["Network integrations"]
  node_wol["Wake-on-LAN<br/>[lgtvremote_cli.py]"]
end

node_user(("CLI user"))
node_tv["LG webOS TV"]
node_lan(("Local network"))

node_user -->|"runs commands"| node_entry
node_entry -->|"dispatches"| node_discovery
node_entry -->|"dispatches"| node_device_mgmt
node_entry -->|"dispatches"| node_power
node_entry -->|"dispatches"| node_remote
node_entry -->|"dispatches"| node_volume
node_entry -->|"dispatches"| node_inputs
node_entry -->|"dispatches"| node_apps
node_entry -->|"dispatches"| node_display
node_discovery -->|"adds found TVs"| node_device_mgmt
node_device_mgmt -->|"pairs devices"| node_pairing
node_device_mgmt -->|"saves device data"| node_config
node_pairing -->|"registers over"| node_ssap
node_pairing -->|"stores pairing key"| node_config
node_ssap -->|"sends SSAP requests"| node_tv
node_discovery -->|"discovers TVs"| node_lan
node_power -->|"controls power"| node_ssap
node_power -->|"wakes TV"| node_wol
node_wol -->|"sends wake packets"| node_lan
node_remote -->|"sends controls"| node_ssap
node_volume -->|"sends audio commands"| node_ssap
node_inputs -->|"queries and switches"| node_ssap
node_apps -->|"launches apps"| node_ssap
node_display -->|"sets display options"| node_ssap

click node_entry "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_discovery "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_device_mgmt "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_config "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_pairing "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_ssap "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_power "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_remote "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_volume "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_inputs "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_apps "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_display "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"
click node_wol "https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_discovery,node_device_mgmt,node_config,node_user toneBlue
class node_pairing,node_ssap toneAmber
class node_power,node_remote,node_volume,node_inputs,node_apps,node_display toneMint
class node_wol toneRose
class node_tv,node_lan toneIndigo
```

## Components

### CLI and devices

- [Command dispatcher](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [TV discovery](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Device management](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Device configuration](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`

### Connection and pairing

- [PIN pairing](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [SSAP WebSocket](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`

### TV controls

- [Power control](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Remote and media](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Audio control](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Inputs and channels](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Apps and URLs](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`
- [Display settings](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`

### Network integrations

- [Wake-on-LAN](https://github.com/griches/lgtvremote-cli/blob/main/lgtvremote_cli.py): `lgtvremote_cli.py`

### Other components

- **CLI user**
- **LG webOS TV**
- **Local network**

## Connections

- CLI user → Command dispatcher: runs commands (evidence: `lgtvremote_cli.py`)
- Command dispatcher → TV discovery: dispatches (evidence: `README.md`)
- Command dispatcher → Device management: dispatches (evidence: `README.md`)
- Command dispatcher → Power control: dispatches (evidence: `lgtvremote_cli.py`)
- Command dispatcher → Remote and media: dispatches (evidence: `README.md`)
- Command dispatcher → Audio control: dispatches (evidence: `README.md`)
- Command dispatcher → Inputs and channels: dispatches (evidence: `README.md`)
- Command dispatcher → Apps and URLs: dispatches (evidence: `README.md`)
- Command dispatcher → Display settings: dispatches (evidence: `README.md`)
- TV discovery → Device management: adds found TVs (evidence: `README.md`)
- Device management → PIN pairing: pairs devices (evidence: `README.md`)
- Device management → Device configuration: saves device data (evidence: `README.md`)
- PIN pairing → SSAP WebSocket: registers over (evidence: `lgtvremote_cli.py`)
- PIN pairing → Device configuration: stores pairing key (evidence: `README.md`)
- SSAP WebSocket → LG webOS TV: sends SSAP requests (evidence: `README.md`)
- TV discovery → Local network: discovers TVs (evidence: `README.md`)
- Power control → SSAP WebSocket: controls power (evidence: `README.md`)
- Power control → Wake-on-LAN: wakes TV (evidence: `README.md`)
- Wake-on-LAN → Local network: sends wake packets (evidence: `lgtvremote_cli.py`)
- Remote and media → SSAP WebSocket: sends controls (evidence: `README.md`)
- Audio control → SSAP WebSocket: sends audio commands (evidence: `README.md`)
- Inputs and channels → SSAP WebSocket: queries and switches (evidence: `README.md`)
- Apps and URLs → SSAP WebSocket: launches apps (evidence: `README.md`)
- Display settings → SSAP WebSocket: sets display options (evidence: `README.md`)
