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

export const linuxBatteryDomain = "linux_battery";
export const linuxBatteryDefaultName = "Linux Battery";

export type TLinuxBatteryRawData = TSimpleLocalRawData;
export interface ILinuxBatterySnapshot extends ISimpleLocalSnapshot {}
export interface ILinuxBatteryConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  sysfsPath?: string;
  batteryPath?: string;
  battery?: number;
  system?: 'android' | 'linux';
}

export const linuxBatteryProfile: ISimpleLocalIntegrationProfile = {
  domain: linuxBatteryDomain,
  displayName: "Linux Battery",
  manufacturer: "Linux Battery",
  model: "Linux Battery local integration",
  defaultName: linuxBatteryDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "linux_battery",
    "Linux Battery",
    "Linux",
    "Battery",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/linux_battery",
    "upstreamDomain": "linux_battery",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [
      "batinfo==0.4.2",
    ],
    "codeowners": [
      "@fabaff",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/linux_battery",
    "loggers": [
      "batinfo",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "implemented": [
        "native read-only polling from Linux/Android power_supply sysfs files under /sys/class/power_supply or configured sysfsPath/batteryPath",
        "manual local setup for Linux Battery snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Linux Battery device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "Linux Battery write/control services: Home Assistant exposes this integration as a read-only sensor backed by batinfo/sysfs",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
