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

export const bthomeDomain = "bthome";
export const bthomeDefaultName = "BTHome";

export interface IBthomeRawData extends Record<string, unknown> {
  temperature?: number;
  humidity?: number;
  battery?: number;
}

export type TBthomeRawData = IBthomeRawData | TSimpleLocalRawData;
export interface IBthomeSnapshot extends ISimpleLocalSnapshot {}
export interface IBthomeConfig extends ISimpleLocalConfig {
  rawData?: TBthomeRawData;
}
export interface IHomeAssistantBthomeConfig extends IBthomeConfig {}

export const bthomeProfile: ISimpleLocalIntegrationProfile = {
  domain: "bthome",
  displayName: "BTHome",
  manufacturer: "BTHome",
  model: "BLE advertisement sensor",
  defaultName: "BTHome",
  defaultProtocol: "local",
  status: "read-only-runtime",
  platforms: [
    "sensor",
    "binary_sensor"
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    "manual",
    "mdns",
    "ssdp",
    "http",
    "custom"
  ],
  discoveryKeywords: [
    "bthome",
    "bluetooth",
    "ble"
  ],
  metadata: {
    source: "home-assistant/core",
    upstreamPath: "homeassistant/components/bthome",
    upstreamDomain: "bthome",
    integrationType: "device",
    iotClass: "local_push",
    requirements: [
      "bthome-ble==3.17.0"
    ],
    dependencies: [
      "bluetooth_adapters"
    ],
    afterDependencies: [],
    codeowners: [
      "@Ernst79",
      "@thecode"
    ],
    configFlow: true,
    sample: {
      temperature: 20.4,
      humidity: 45,
      battery: 86
    },
    runtime: {
      type: "read-only-runtime",
      services: [
        "snapshot",
        "status",
        "refresh"
      ],
      platforms: [
        "sensor",
        "binary_sensor"
      ],
      controls: false
    },
    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"
      ]
    }
  }
};
