@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
28 lines (23 loc) • 821 B
text/typescript
import { OnOffLightRequirements } from '@matter/node/devices/on-off-light';
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 OnOffSwitchBehavior extends ISYClusterBehavior(OnOffLightRequirements.OnOffServer, Devices.ZigBee.ExtendedColorLight) {
override async initialize(_options?: {}) {
await super.initialize(_options);
}
override on = async () => {
if (!this.state.onOff) {
await this.device.onOff.on();
this.state.onOff = true;
}
};
override async off(): Promise<void> {
if (this.state.onOff) {
await this.device.onOff.off();
this.state.onOff = false;
}
}
}
BehaviorRegistry.register(OnOffSwitchBehavior);