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

export const fileDomain = 'file';
export const fileDefaultName = 'File';

export type TFilePlatform = 'sensor' | 'notify';
export type TFileRawData = TSimpleLocalRawData;
export interface IFileSnapshot extends ISimpleLocalSnapshot {}
export interface IFileConfig extends ISimpleLocalConfig {
  filePath?: string;
  file_path?: string;
  platform?: TFilePlatform | string;
  unitOfMeasurement?: string;
  unit_of_measurement?: string;
  valueTemplate?: string;
  value_template?: string;
  timestamp?: boolean;
}
export interface IHomeAssistantFileConfig extends IFileConfig {}

export const fileProfile: ISimpleLocalIntegrationProfile = {
  domain: 'file',
  displayName: 'File',
  manufacturer: 'Home Assistant',
  model: 'Local File',
  defaultName: fileDefaultName,
  defaultProtocol: 'local',
  status: 'read-only-runtime',
  platforms: [
    'sensor',
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'file',
    'file sensor',
    'local file',
    'read_file',
    'notify',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/file',
    upstreamDomain: 'file',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'file-read-backwards==2.0.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@fabaff',
    ],
    configFlow: true,
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
      ],
      platforms: [
        'notify',
        'sensor',
      ],
      controls: false,
    },
    localApi: {
      implemented: [
        'manual local file path setup, snapshots, raw data, snapshotProvider, and injected native clients',
        'read-only local file sensor snapshots from config.filePath or config.file_path',
      ],
      explicitUnsupported: [
        'writing notification messages without injected client.execute or commandExecutor',
        'claiming live command success without injected client.execute or commandExecutor',
        'Home Assistant template rendering and YAML read_file decoding in the native runtime',
      ],
    },
  },
};
