import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { EmonitorClient } from './emonitor.classes.client.js';
import { EmonitorConfigFlow } from './emonitor.classes.configflow.js';
import { createEmonitorDiscoveryDescriptor } from './emonitor.discovery.js';
import type { IEmonitorConfig } from './emonitor.types.js';
import { emonitorDomain, emonitorProfile } from './emonitor.types.js';

export class EmonitorIntegration extends SimpleLocalIntegration<IEmonitorConfig> {
  public readonly domain = emonitorDomain;
  public readonly discoveryDescriptor = createEmonitorDiscoveryDescriptor();
  public readonly configFlow = new EmonitorConfigFlow();

  constructor() {
    super(emonitorProfile);
  }

  public async setup(configArg: IEmonitorConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(emonitorProfile, new EmonitorClient(configArg));
  }
}

export class HomeAssistantEmonitorIntegration extends EmonitorIntegration {}
