# o-lukas/homebridge-smartthings-tv architecture

> Architecture diagram of the GitHub repository o-lukas/homebridge-smartthings-tv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/o-lukas/homebridge-smartthings-tv
- Repository: https://github.com/o-lukas/homebridge-smartthings-tv

## Overview

This Homebridge plugin discovers Samsung TVs and soundbars through SmartThings, registers them as Homebridge television accessories, and maps HomeKit controls to SmartThings capabilities. The main workflow is Homebridge registration → platform configuration/authentication → device discovery and type-specific registration → accessory reads and commands. Separate controls cover art mode, switches, sliders, inputs, volume, and TV applications; the UI server supports OAuth code and token exchange. Relationships are limited to calls and references visible in the excerpts or explicit README statements; unsampled implementation details are not inferred.

Main entry points: [`src/smartThingsPlatform.ts`](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsPlatform.ts) (Device discovery and registration), [`src/smartThingsAccessory.ts`](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsAccessory.ts) (Capability access and polling), [`src/tvAccessory.ts`](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/tvAccessory.ts) (TV controls), [`src/index.ts`](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/index.ts) (Platform registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform lifecycle"]
  node_entry["Platform registration<br/>[index.ts]"]
  node_settings["Platform identifiers<br/>[settings.ts]"]
  node_platform_impl["Device discovery and registration"]
end

subgraph group_devices["Device adapters"]
  node_tv["TV controls<br/>[tvAccessory.ts]"]
  node_soundbar["Soundbar controls"]
  node_base["Capability access and polling"]
  node_apps["TV application catalog<br/>[tvApps.ts]"]
end

subgraph group_controls["Accessory controls"]
  node_switch["Capability switch<br/>[switchAccessory.ts]"]
  node_slider["Capability slider<br/>[sliderAccessory.ts]"]
  node_art_mode["Art mode switch"]
end

subgraph group_auth["OAuth configuration"]
  node_ui_server["OAuth UI endpoints<br/>[server.js]"]
end

node_user(("Plugin user"))
node_homebridge{{"Homebridge"}}
node_st_api{{"SmartThings API"}}
node_config_ui(("Homebridge Config UI"))
node_oauth_service{{"SmartThings OAuth"}}

node_user -->|"configures plugin"| node_homebridge
node_homebridge -->|"loads platform"| node_entry
node_entry -->|"uses identifiers"| node_settings
node_entry -->|"registers platform"| node_platform_impl
node_platform_impl -->|"lists devices"| node_st_api
node_platform_impl -->|"registers TV"| node_tv
node_platform_impl -->|"registers soundbar"| node_soundbar
node_platform_impl -->|"registers switch"| node_switch
node_platform_impl -->|"registers slider"| node_slider
node_platform_impl -->|"registers art switch"| node_art_mode
node_tv -->|"inherits capability access"| node_base
node_soundbar -->|"inherits capability access"| node_base
node_switch -->|"delegates capability access"| node_base
node_slider -->|"delegates capability access"| node_base
node_art_mode -->|"inherits capability access"| node_base
node_base -->|"reads status and sends commands"| node_st_api
node_tv -->|"fetches capabilities and launches apps"| node_st_api
node_soundbar -->|"fetches capabilities"| node_st_api
node_tv -->|"uses application catalog"| node_apps
node_art_mode -->|"calls art mode controls"| node_tv
node_user -->|"configures OAuth"| node_config_ui
node_config_ui -.->|"requests OAuth endpoints"| node_ui_server
node_ui_server -->|"exchanges authorization code"| node_oauth_service

click node_entry "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/index.ts"
click node_settings "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/settings.ts"
click node_platform_impl "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsPlatform.ts"
click node_tv "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/tvAccessory.ts"
click node_soundbar "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/soundbarAccessory.ts"
click node_base "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsAccessory.ts"
click node_apps "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/tvApps.ts"
click node_switch "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/switchAccessory.ts"
click node_slider "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/sliderAccessory.ts"
click node_art_mode "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/artModeSwitchAccessory.ts"
click node_ui_server "https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/homebridge-ui/server.js"

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_settings,node_platform_impl,node_user,node_config_ui toneBlue
class node_tv,node_soundbar,node_base,node_apps toneAmber
class node_switch,node_slider,node_art_mode,node_st_api toneMint
class node_ui_server toneRose
class node_homebridge,node_oauth_service toneIndigo
```

## Components

### Platform lifecycle

- [Platform registration](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/index.ts): `src/index.ts`
- [Platform identifiers](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/settings.ts): `src/settings.ts`
- [Device discovery and registration](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsPlatform.ts): `src/smartThingsPlatform.ts`

### Device adapters

- [TV controls](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/tvAccessory.ts): `src/tvAccessory.ts`
- [Soundbar controls](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/soundbarAccessory.ts): `src/soundbarAccessory.ts`
- [Capability access and polling](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/smartThingsAccessory.ts): `src/smartThingsAccessory.ts`
- [TV application catalog](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/tvApps.ts): `src/tvApps.ts`

### Accessory controls

- [Capability switch](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/switchAccessory.ts): `src/switchAccessory.ts`
- [Capability slider](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/sliderAccessory.ts): `src/sliderAccessory.ts`
- [Art mode switch](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/src/artModeSwitchAccessory.ts): `src/artModeSwitchAccessory.ts`

### OAuth configuration

- [OAuth UI endpoints](https://github.com/o-lukas/homebridge-smartthings-tv/blob/main/homebridge-ui/server.js): `homebridge-ui/server.js`

### Other components

- **Plugin user**
- **Homebridge**
- **SmartThings API**
- **Homebridge Config UI**
- **SmartThings OAuth**

## Connections

- Plugin user → Homebridge: configures plugin (evidence: `README.md`)
- Homebridge → Platform registration: loads platform (evidence: `src/index.ts`)
- Platform registration → Platform identifiers: uses identifiers (evidence: `src/index.ts`)
- Platform registration → Device discovery and registration: registers platform (evidence: `src/index.ts`)
- Device discovery and registration → SmartThings API: lists devices (evidence: `src/smartThingsPlatform.ts`)
- Device discovery and registration → TV controls: registers TV (evidence: `src/smartThingsPlatform.ts`)
- Device discovery and registration → Soundbar controls: registers soundbar (evidence: `src/smartThingsPlatform.ts`)
- Device discovery and registration → Capability switch: registers switch (evidence: `src/smartThingsPlatform.ts`)
- Device discovery and registration → Capability slider: registers slider (evidence: `src/smartThingsPlatform.ts`)
- Device discovery and registration → Art mode switch: registers art switch (evidence: `src/smartThingsPlatform.ts`)
- TV controls → Capability access and polling: inherits capability access (evidence: `src/tvAccessory.ts`)
- Soundbar controls → Capability access and polling: inherits capability access (evidence: `src/soundbarAccessory.ts`)
- Capability switch → Capability access and polling: delegates capability access (evidence: `src/switchAccessory.ts`)
- Capability slider → Capability access and polling: delegates capability access (evidence: `src/sliderAccessory.ts`)
- Art mode switch → Capability access and polling: inherits capability access (evidence: `src/artModeSwitchAccessory.ts`)
- Capability access and polling → SmartThings API: reads status and sends commands (evidence: `src/smartThingsAccessory.ts`)
- TV controls → SmartThings API: fetches capabilities and launches apps (evidence: `src/tvAccessory.ts`)
- Soundbar controls → SmartThings API: fetches capabilities (evidence: `src/soundbarAccessory.ts`)
- TV controls → TV application catalog: uses application catalog (evidence: `src/tvAccessory.ts`)
- Art mode switch → TV controls: calls art mode controls (evidence: `src/artModeSwitchAccessory.ts`)
- Plugin user → Homebridge Config UI: configures OAuth (evidence: `README.md`)
- Homebridge Config UI → OAuth UI endpoints: requests OAuth endpoints
- OAuth UI endpoints → SmartThings OAuth: exchanges authorization code (evidence: `homebridge-ui/server.js`)
