import { DimmableLightRequirements } from '@matter/node/devices';
import { Identify } from '@matter/main/clusters';

import { ISYClusterBehavior } from '../ISYClusterBehavior.js';
import { BehaviorRegistry } from '../BehaviorRegistry.js';
import { Devices } from 'isy-nodejs/ISY';

export class IdentifyBehavior extends ISYClusterBehavior(DimmableLightRequirements.IdentifyServer, Devices.Insteon.RelayLamp) {

	override async initialize() {
		await super.initialize();
		this.state.identifyType = Identify.IdentifyType.AudibleBeep;
	}
	override async identify() {
		return this.device.beep(100);
	}

	override async triggerEffect(request: Identify.TriggerEffectRequest) {
		switch (request.effectIdentifier) {
			case Identify.EffectIdentifier.Blink:
				return this.device.fastOn().then(() => this.device.fastOff());
			default:
				return this.device.beep(100);
		}
	}
}

BehaviorRegistry.register(IdentifyBehavior);
