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

export const melnorDomain = "melnor";
export const melnorDefaultName = "Melnor Bluetooth";

export type TMelnorRawData = TSimpleLocalRawData;
export interface IMelnorSnapshot extends ISimpleLocalSnapshot {}
export interface IMelnorConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export const melnorProfile: ISimpleLocalIntegrationProfile = {
  domain: melnorDomain,
  displayName: "Melnor Bluetooth",
  manufacturer: "Melnor Bluetooth",
  model: "Melnor Bluetooth local integration",
  defaultName: melnorDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "number",
    "sensor",
    "switch",
  ],
  serviceDomains: [
    "number",
    "switch",
  ],
  controlServices: [
    "set_value",
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "melnor",
    "Melnor Bluetooth",
    "Melnor",
    "Bluetooth",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/melnor",
    "upstreamDomain": "melnor",
    "integrationType": "device",
    "iotClass": "local_polling",
    "requirements": [
      "melnor-bluetooth==0.0.25",
    ],
    "dependencies": [
      "bluetooth_adapters",
    ],
    "codeowners": [
      "@vanstinator",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/melnor",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "set_value",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "number",
        "sensor",
        "switch",
      ],
      "controls": "delegated only to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "manual setup for Melnor Bluetooth snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Melnor Bluetooth snapshot data and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only; no native BLE transport is claimed",
      ],
      "explicitUnsupported": [
        "native Melnor live polling and writes because Home Assistant uses melnor-bluetooth==0.0.25 over bleak Bluetooth Low Energy, not a documented local HTTP/TCP/TLS/file protocol",
        "Bluetooth discovery, pairing, reconnect, and GATT characteristic handling without an available BLE stack dependency",
        "claiming live Melnor Bluetooth polling, subscription, 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",
      ],
    },
  },
};
