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

export const orviboDomain = "orvibo";
export const orviboDefaultName = "Orvibo";

export type TOrviboRawData = TSimpleLocalRawData;
export interface IOrviboSnapshot extends ISimpleLocalSnapshot {}
export interface IOrviboConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantOrviboConfig extends IOrviboConfig {}

export const orviboProfile: ISimpleLocalIntegrationProfile = {
  domain: orviboDomain,
  displayName: "Orvibo",
  manufacturer: "Orvibo",
  model: "Orvibo local integration",
  defaultName: orviboDefaultName,
  defaultProtocol: 'local',
  status: "control-runtime",
  platforms: [
    "switch",
  ],
  serviceDomains: [
    "switch",
  ],
  controlServices: [
    "toggle",
    "turn_off",
    "turn_on",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "orvibo",
    "Orvibo",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/orvibo",
    "upstreamDomain": "orvibo",
    "integrationType": "device",
    "iotClass": "local_push",
    "qualityScale": "legacy",
    "requirements": [
      "orvibo==1.1.2",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/orvibo",
    "loggers": [
      "orvibo",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "toggle",
        "turn_off",
        "turn_on",
      ],
      "platforms": [
        "switch",
      ],
      "controls": "snapshot/rawData/injected-client only; native live Orvibo S20 control is blocked because HA's orvibo==1.1.2 uses a UDP-only binary protocol on port 10000",
    },
    "localApi": {
      "implemented": [
        "manual local setup for Orvibo endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Orvibo device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only; no native live UDP implementation is claimed",
      ],
      "explicitUnsupported": [
        "native live Orvibo S20 polling/control: Home Assistant's orvibo==1.1.2 uses a UDP-only binary protocol on port 10000 with broadcast discovery, subscription, status, and control packets",
        "claiming live Orvibo polling, pairing, 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",
      ],
    },
  },
};
