import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OpenevseClient } from './openevse.classes.client.js';
import { OpenevseConfigFlow } from './openevse.classes.configflow.js';
import { createOpenevseDiscoveryDescriptor } from './openevse.discovery.js';
import type { IOpenevseConfig } from './openevse.types.js';
import { openevseDomain, openevseProfile } from './openevse.types.js';

export class OpenevseIntegration extends SimpleLocalIntegration<IOpenevseConfig> {
  public readonly domain = openevseDomain;
  public readonly discoveryDescriptor = createOpenevseDiscoveryDescriptor();
  public readonly configFlow = new OpenevseConfigFlow();

  constructor() {
    super(openevseProfile);
  }

  public override async setup(configArg: IOpenevseConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(openevseProfile, new OpenevseClient(configArg));
  }
}

export class HomeAssistantOpenevseIntegration extends OpenevseIntegration {}
