

import { Devices } from 'isy-nodejs/ISY';
import { ISYClusterBehavior, type PropertyChange } from '../ISYClusterBehavior.js';
import { BehaviorRegistry } from '../BehaviorRegistry.js';
import { OnOffLightRequirements } from '@matter/main/devices';
import type { ISYNode } from 'isy-nodejs/ISYNode';


export class RelayOnOffBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, Devices.Insteon.RelayLamp as ISYNode.Factory<any,any>) {
	override async initialize(_options?: {}) {
		await super.initialize(_options);

		//this.state.onOff = this.device.status;
		//this.state.onOff = await this.device.state;
	}

	override on = async () => {
		if(!this.state.onOff)
		{
			await this.device.on();
			this.state.onOff = true;
		}



		//this.device.commands.DON = true;
	};

	override async off() {
		if(this.state.onOff)
		{

		 	await this.device.off();
		 	this.state.onOff = false;
		}

		 //this.state.onOff = false;

		// this.device.drivers = false;
	}
}

BehaviorRegistry.register(RelayOnOffBehavior);
