# jameslb/cync_lights architecture

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

- Interactive diagram: https://gitdiagram.com/jameslb/cync_lights
- Repository: https://github.com/jameslb/cync_lights

## Overview

This Home Assistant integration authenticates a Cync account, discovers its homes and devices, lets users choose which rooms and devices to expose, and provides controls and sensor state in Home Assistant. The hub owns the Cync connection and device state; platform entities expose lights, fans, plugs, motion sensors, and ambient-light sensors. The excerpts show setup, platform access, and entity commands, but not the full network protocol, so the Cync service connection is shown as unverified.

Main entry points: [`custom_components/cync_lights/__init__.py`](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/__init__.py) (Entry lifecycle), [`custom_components/cync_lights/cync_hub.py`](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/cync_hub.py) (Cync hub and device state), [`custom_components/cync_lights/config_flow.py`](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/config_flow.py) (Setup and options), [`custom_components/cync_lights/light.py`](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/light.py) (Room and switch lights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Account setup"]
  node_config_flow["Setup and options<br/>[config_flow.py]"]
end

subgraph group_runtime["Integration runtime"]
  node_domain["Integration domain<br/>[const.py]"]
  node_lifecycle["Entry lifecycle<br/>[__init__.py]"]
  node_hub["Cync hub and device state<br/>[cync_hub.py]"]
end

subgraph group_controls["Device controls"]
  node_light_platform["Room and switch lights<br/>[light.py]"]
  node_fan_platform["Fan controls<br/>[fan.py]"]
  node_plug_platform["Plug controls<br/>[switch.py]"]
end

subgraph group_sensors["Device sensors"]
  node_sensor_platform["Motion and ambient sensors<br/>[binary_sensor.py]"]
end

node_user(("Home Assistant user"))
node_cync_service{{"Cync service"}}

node_user -->|"configures account"| node_config_flow
node_config_flow -->|"authenticates and discovers"| node_hub
node_user -->|"selects devices"| node_config_flow
node_lifecycle -->|"uses domain key"| node_domain
node_lifecycle -->|"creates and starts"| node_hub
node_lifecycle -->|"forwards setup"| node_light_platform
node_lifecycle -->|"forwards setup"| node_sensor_platform
node_lifecycle -->|"forwards setup"| node_fan_platform
node_lifecycle -->|"forwards setup"| node_plug_platform
node_light_platform -->|"reads state; sends commands"| node_hub
node_fan_platform -->|"reads state; sends commands"| node_hub
node_plug_platform -->|"reads state; sends commands"| node_hub
node_sensor_platform -->|"reads sensor state"| node_hub
node_hub -.->|"exchanges device data"| node_cync_service

click node_config_flow "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/config_flow.py"
click node_domain "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/const.py"
click node_lifecycle "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/__init__.py"
click node_hub "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/cync_hub.py"
click node_light_platform "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/light.py"
click node_fan_platform "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/fan.py"
click node_plug_platform "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/switch.py"
click node_sensor_platform "https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/binary_sensor.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_config_flow,node_user toneBlue
class node_domain,node_lifecycle,node_hub toneAmber
class node_light_platform,node_fan_platform,node_plug_platform toneMint
class node_sensor_platform toneRose
class node_cync_service toneIndigo
```

## Components

### Account setup

- [Setup and options](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/config_flow.py): `custom_components/cync_lights/config_flow.py`

### Integration runtime

- [Integration domain](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/const.py): `custom_components/cync_lights/const.py`
- [Entry lifecycle](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/__init__.py): `custom_components/cync_lights/__init__.py`
- [Cync hub and device state](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/cync_hub.py): `custom_components/cync_lights/cync_hub.py`

### Device controls

- [Room and switch lights](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/light.py): `custom_components/cync_lights/light.py`
- [Fan controls](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/fan.py): `custom_components/cync_lights/fan.py`
- [Plug controls](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/switch.py): `custom_components/cync_lights/switch.py`

### Device sensors

- [Motion and ambient sensors](https://github.com/jameslb/cync_lights/blob/main/custom_components/cync_lights/binary_sensor.py): `custom_components/cync_lights/binary_sensor.py`

### Other components

- **Home Assistant user**
- **Cync service**

## Connections

- Home Assistant user → Setup and options: configures account (evidence: `README.md`)
- Setup and options → Cync hub and device state: authenticates and discovers (evidence: `custom_components/cync_lights/config_flow.py`)
- Home Assistant user → Setup and options: selects devices (evidence: `README.md`)
- Entry lifecycle → Integration domain: uses domain key (evidence: `custom_components/cync_lights/__init__.py`)
- Entry lifecycle → Cync hub and device state: creates and starts (evidence: `custom_components/cync_lights/__init__.py`)
- Entry lifecycle → Room and switch lights: forwards setup (evidence: `custom_components/cync_lights/__init__.py`)
- Entry lifecycle → Motion and ambient sensors: forwards setup (evidence: `custom_components/cync_lights/__init__.py`)
- Entry lifecycle → Fan controls: forwards setup (evidence: `custom_components/cync_lights/__init__.py`)
- Entry lifecycle → Plug controls: forwards setup (evidence: `custom_components/cync_lights/__init__.py`)
- Room and switch lights → Cync hub and device state: reads state; sends commands (evidence: `custom_components/cync_lights/light.py`)
- Fan controls → Cync hub and device state: reads state; sends commands (evidence: `custom_components/cync_lights/fan.py`)
- Plug controls → Cync hub and device state: reads state; sends commands (evidence: `custom_components/cync_lights/switch.py`)
- Motion and ambient sensors → Cync hub and device state: reads sensor state (evidence: `custom_components/cync_lights/binary_sensor.py`)
- Cync hub and device state → Cync service: exchanges device data
