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

export const ubusDomain = "ubus";
export const ubusDefaultName = "OpenWrt (ubus)";

export type TUbusRawData = TSimpleLocalRawData;
export interface IUbusSnapshot extends ISimpleLocalSnapshot {}
export interface IUbusConfig extends ISimpleLocalConfig {}
export interface IHomeAssistantUbusConfig extends IUbusConfig {}

export const ubusProfile: ISimpleLocalIntegrationProfile = {
  domain: "ubus",
  displayName: "OpenWrt (ubus)",
  manufacturer: "OpenWrt",
  model: "ubus router",
  defaultName: "OpenWrt (ubus)",
  defaultPort: 80,
  defaultHttpPath: "/ubus",
  defaultProtocol: "http",
  status: "control-runtime",
  platforms: [
    "sensor",
    "switch",
    "binary_sensor"
  ],
  serviceDomains: [
    "switch"
  ],
  controlServices: [
    "turn_on",
    "turn_off",
    "toggle"
  ],
  discoverySources: [
    "manual",
    "mdns",
    "ssdp",
    "http",
    "custom"
  ],
  discoveryKeywords: [
    "openwrt",
    "ubus",
    "router"
  ],
  metadata: {
    source: "home-assistant/core",
    upstreamPath: "homeassistant/components/ubus",
    upstreamDomain: "ubus",
    iotClass: "local_polling",
    qualityScale: "legacy",
    requirements: [
      "openwrt-ubus-rpc==0.0.2"
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [],
    configFlow: true,
    runtime: {
      type: "control-runtime",
      services: [
        "snapshot",
        "status",
        "refresh",
        "turn_on",
        "turn_off",
        "toggle"
      ],
      platforms: [
        "sensor",
        "switch",
        "binary_sensor"
      ],
      controls: true
    },
    localApi: {
      implemented: [
        "manual local endpoint setup",
        "snapshot, raw data, snapshotProvider, and injected native client operation",
        "generic HTTP/TCP local transport when config.path, config.transport, or documented defaults are supplied"
      ],
      explicitUnsupported: [
        "claiming live command success without injected client.execute or commandExecutor",
        "cloud account flows and remote API polling",
        "device-specific protocol features not represented by snapshot/rawData/client/executor inputs"
      ]
    }
  }
};
