import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const lutronDomain = "lutron";
export const lutronDefaultName = "Lutron";

export type TLutronRawData = TSimpleLocalRawData;
export interface ILutronSnapshot extends ISimpleLocalSnapshot {}
export interface ILutronConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  httpPort?: number;
  telnetPort?: number;
  xmlPath?: string;
  queryStates?: boolean;
}
export interface IHomeAssistantLutronConfig extends ILutronConfig {}

export const lutronProfile: ISimpleLocalIntegrationProfile = {
  domain: lutronDomain,
  displayName: "Lutron",
  manufacturer: "Lutron",
  model: "Lutron local integration",
  defaultName: lutronDefaultName,
  defaultPort: 23,
  defaultHttpPath: '/DbXmlInfo.xml',
  defaultProtocol: 'telnet',
  status: "control-runtime",
  platforms: [
    "binary_sensor",
    "button",
    "cover",
    "fan",
    "light",
    "select",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "button",
    "cover",
    "fan",
    "light",
    "select",
    "switch",
  ],
  controlServices: [
    "close_cover",
    "open_cover",
    "press",
    "select_option",
    "stop_cover",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "lutron",
    "Lutron",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/lutron",
    "upstreamDomain": "lutron",
    "integrationType": "hub",
    "iotClass": "local_polling",
    "requirements": [
      "pylutron==0.4.1",
    ],
    "codeowners": [
      "@cdheiser",
      "@wilburCForce",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/lutron",
    "loggers": [
      "pylutron",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "close_cover",
        "open_cover",
        "press",
        "select_option",
        "stop_cover",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "binary_sensor",
        "button",
        "cover",
        "fan",
        "light",
        "select",
        "sensor",
        "switch",
      ],
      "polling": "native local RadioRA 2 Main Repeater /DbXmlInfo.xml HTTP topology reads plus Telnet OUTPUT state queries when credentials are configured",
      "controls": "native local RadioRA 2 Telnet OUTPUT/DEVICE commands when host, username, and password are configured; otherwise delegated only to injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "native RadioRA 2 HTTP XML and Telnet implemented; Caseta/RA3 LEAP remains in lutron_caseta and is not handled here",
      "implemented": [
        "native RadioRA 2 Main Repeater /DbXmlInfo.xml local HTTP parsing for areas, outputs, occupancy groups, and keypad buttons",
        "native RadioRA 2 Telnet login, OUTPUT level queries, OUTPUT writes, DEVICE button presses, and keypad LED state commands",
        "manual local setup for Lutron endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Lutron device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when native Telnet is not configured",
      ],
      "explicitUnsupported": [
        "native RadioRA 2 push event subscription monitoring; snapshots use HTTP XML plus optional Telnet queries",
        "Lutron Caseta/RA2 Select/RadioRA 3/HomeWorks QSX LEAP pairing and mutual-TLS protocol in the lutron domain",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
