@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
37 lines (28 loc) • 996 B
text/typescript
import { OnOffLightRequirements } from '@matter/main/devices';
import { Devices } from 'isy-nodejs/ISY';
import type { ISYNode } from 'isy-nodejs/ISYNode';
import { BehaviorRegistry } from '../BehaviorRegistry.js';
import { ISYClusterBehavior } from '../ISYClusterBehavior.js';
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);