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

export const gardenaBluetoothDomain = 'gardena_bluetooth';
export const gardenaBluetoothDefaultName = 'Gardena Bluetooth';
export const gardenaBluetoothServiceUuid = '98bd0001-0b0e-421a-84e5-ddbf75dc6de4';

export type TGardenaBluetoothRawData = TSimpleLocalRawData;
export interface IGardenaBluetoothSnapshot extends ISimpleLocalSnapshot {}
export interface IGardenaBluetoothConfig extends ISimpleLocalConfig {
  address?: string;
  productType?: string;
}
export interface IHomeAssistantGardenaBluetoothConfig extends IGardenaBluetoothConfig {}

export const gardenaBluetoothProfile: ISimpleLocalIntegrationProfile = {
  domain: gardenaBluetoothDomain,
  displayName: 'Gardena Bluetooth',
  manufacturer: 'Gardena',
  model: 'Bluetooth device',
  defaultName: gardenaBluetoothDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'binary_sensor',
    'button',
    'number',
    'select',
    'sensor',
    'switch',
    'text',
  ],
  serviceDomains: [
    'binary_sensor',
    'button',
    'number',
    'select',
    'sensor',
    'switch',
    'text',
    'valve',
  ],
  controlServices: [
    'open_valve',
    'close_valve',
    'turn_on',
    'turn_off',
    'set_value',
    'select_option',
    'set_text',
    'press',
  ],
  discoverySources: [
    'manual',
    'bluetooth',
    'custom',
  ],
  discoveryKeywords: [
    'gardena',
    'gardena bluetooth',
    'aqua contour',
    'water computer',
    gardenaBluetoothServiceUuid,
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/gardena_bluetooth',
    upstreamDomain: 'gardena_bluetooth',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'gardena-bluetooth==2.4.0',
    ],
    dependencies: [
      'bluetooth_adapters',
    ],
    afterDependencies: [],
    codeowners: [
      '@elupus',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/gardena_bluetooth',
    loggers: [
      'bleak',
      'bleak_esphome',
      'gardena_bluetooth',
    ],
    bluetooth: [
      {
        connectable: true,
        manufacturerId: 1062,
        serviceUuid: gardenaBluetoothServiceUuid,
      },
    ],
    platforms: [
      'binary_sensor',
      'button',
      'number',
      'select',
      'sensor',
      'switch',
      'text',
      'valve',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'open_valve',
        'close_valve',
        'turn_on',
        'turn_off',
        'set_value',
        'select_option',
        'set_text',
        'press',
      ],
      platforms: [
        'binary_sensor',
        'button',
        'number',
        'select',
        'sensor',
        'switch',
        'text',
        'valve',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual and Bluetooth-seeded setup for Gardena device address, product metadata, snapshots, raw data, snapshotProvider, and injected native clients',
        'runtime mapping for Gardena Bluetooth sensor, binary sensor, number, select, switch, text, button, and valve-style snapshots',
        'safe write delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native BLE scanning, cached connections, characteristic decode, and characteristic writes in this TypeScript package',
        'claiming valve, number, select, text, or button write success without an injected client.execute or commandExecutor',
        'Home Assistant Bluetooth adapter selection and config entry device registry setup',
      ],
    },
  },
};
