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

export const modemCalleridDomain = "modem_callerid";
export const modemCalleridDefaultName = "Phone Modem";

export type TModemCalleridRawData = TSimpleLocalRawData;
export interface IModemCalleridSnapshot extends ISimpleLocalSnapshot {}
export interface IModemCalleridConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantModemCalleridConfig extends IModemCalleridConfig {}

export const modemCalleridProfile: ISimpleLocalIntegrationProfile = {
  domain: modemCalleridDomain,
  displayName: "Phone Modem",
  manufacturer: "Phone Modem",
  model: "Phone Modem local integration",
  defaultName: modemCalleridDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "button",
    "sensor",
  ],
  serviceDomains: [
    "button",
  ],
  controlServices: [
    "press",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "modem_callerid",
    "Phone Modem",
    "Modem Callerid",
    "Phone",
    "Modem",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/modem_callerid",
    "upstreamDomain": "modem_callerid",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "phone-modem==0.1.1",
    ],
    "dependencies": [
      "usb",
    ],
    "codeowners": [
      "@tkdrob",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/modem_callerid",
    "loggers": [
      "phone_modem",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "press",
      ],
      "platforms": [
        "button",
        "sensor",
      ],
      "controls": "blocked for native live access: HA uses phone-modem/aioserial over a serial TTY; only injected client.execute or commandExecutor may claim reject-call button success",
    },
    "localApi": {
      "status": "native live access unsupported: Home Assistant uses phone-modem with aioserial against a Hayes AT serial TTY device, and this package has no serial stack or local HTTP/TCP/TLS/file API to call",
      "implemented": [
        "manual local setup for Phone Modem endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Phone Modem device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "live Phone Modem caller ID polling because HA opens a serial TTY with phone-modem/aioserial and parses Hayes AT responses (AT, AT+VCID=1, RING, DATE, NMBR, NAME)",
        "live reject-call button because HA sends serial ATA/ATH commands through phone-modem, not an HTTP/TCP/TLS/file protocol",
        "USB/serial discovery and pairing because it requires a serial stack and Home Assistant usb helpers",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
