import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MysensorsClient } from './mysensors.classes.client.js';
import { MysensorsConfigFlow } from './mysensors.classes.configflow.js';
import { createMysensorsDiscoveryDescriptor } from './mysensors.discovery.js';
import type { IMysensorsConfig } from './mysensors.types.js';
import { mysensorsDomain, mysensorsProfile } from './mysensors.types.js';

export class MysensorsIntegration extends SimpleLocalIntegration<IMysensorsConfig> {
  public readonly domain = mysensorsDomain;
  public readonly discoveryDescriptor = createMysensorsDiscoveryDescriptor();
  public readonly configFlow = new MysensorsConfigFlow();

  constructor() {
    super(mysensorsProfile);
  }

  public async setup(configArg: IMysensorsConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mysensorsProfile, new MysensorsClient(configArg));
  }
}

export class HomeAssistantMysensorsIntegration extends MysensorsIntegration {}
