import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { ObihaiClient } from './obihai.classes.client.js';
import { ObihaiConfigFlow } from './obihai.classes.configflow.js';
import { createObihaiDiscoveryDescriptor } from './obihai.discovery.js';
import type { IObihaiConfig } from './obihai.types.js';
import { obihaiDomain, obihaiProfile } from './obihai.types.js';

export class ObihaiIntegration extends SimpleLocalIntegration<IObihaiConfig> {
  public readonly domain = obihaiDomain;
  public readonly discoveryDescriptor = createObihaiDiscoveryDescriptor();
  public readonly configFlow = new ObihaiConfigFlow();

  constructor() {
    super(obihaiProfile);
  }

  public override async setup(configArg: IObihaiConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(obihaiProfile, new ObihaiClient(configArg));
  }
}

export class HomeAssistantObihaiIntegration extends ObihaiIntegration {}
