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

export const opendisplayDomain = "opendisplay";
export const opendisplayDefaultName = "OpenDisplay";

export type TOpendisplayRawData = TSimpleLocalRawData;
export interface IOpendisplaySnapshot extends ISimpleLocalSnapshot {}
export interface IOpendisplayConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOpendisplayConfig extends IOpendisplayConfig {}

export const opendisplayProfile: ISimpleLocalIntegrationProfile = {
  domain: opendisplayDomain,
  displayName: "OpenDisplay",
  manufacturer: "OpenDisplay",
  model: "OpenDisplay local integration",
  defaultName: opendisplayDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [
    "upload_image",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "opendisplay",
    "OpenDisplay",
    "Opendisplay",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/opendisplay",
    "upstreamDomain": "opendisplay",
    "integrationType": "device",
    "iotClass": "local_push",
    "qualityScale": "silver",
    "requirements": [
      "py-opendisplay==5.9.0",
    ],
    "dependencies": [
      "bluetooth_adapters",
      "http",
    ],
    "codeowners": [
      "@g4bri3lDev",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/opendisplay",
    "loggers": [
      "opendisplay",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "upload_image",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "status": "No native TypeScript live client is implemented: Home Assistant uses py-opendisplay with Bleak for BLE advertisements, active BLE connections, optional AES authentication, firmware reads, and image upload; this repo has no BLE stack dependency.",
      "implemented": [
        "manual local setup for OpenDisplay endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for OpenDisplay device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native OpenDisplay BLE discovery, advertisement parsing, active GATT connections, pairing/authentication, firmware reads, and upload_image; HA depends on py-opendisplay/Bleak and a working Bluetooth adapter/proxy, but this repo has no BLE stack dependency",
        "claiming live OpenDisplay polling, pairing, subscription, image upload, or write success without an injected native client or snapshotProvider",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
