@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
28 lines • 1.49 kB
JavaScript
import { FanDevice } from '@matter/node/devices';
import { FanControl } from '@matter/main/clusters';
import { Converter } from 'isy-nodejs/Converters';
import { Devices } from 'isy-nodejs/ISY';
import { BehaviorRegistry } from '../BehaviorRegistry.js';
import { ISYClusterBehavior } from '../ISYClusterBehavior.js';
export class FanControlBehavior extends ISYClusterBehavior(FanDevice.requirements.FanControlServer, Devices.Insteon.Fan) {
async initialize(_options) {
await super.initialize(_options);
this.state.fanModeSequence = FanControl.FanModeSequence.OffLowMedHigh;
this.state.percentCurrent = this.device?.motor.status ?? 0;
this.events.fanMode$Changed.on(async (value, oldValue, context) => {
if (!context.offline) {
this.logger.debug(`Request received to update fanMode to ${FanControl.FanMode[value]}`);
return await this.device.motor.on(Converter.Matter.FanLevel.FanMode.from(value));
}
});
this.events.percentSetting$Changed.on(async (value, oldValue, context) => {
if (!context.offline) {
this.logger.debug(`Request received to update percentSetting to ${value}`);
//let newVal = Converter.Standard.LevelFrom0To255.Percent.from(value);
return await this.device.motor.on(value);
}
});
}
}
BehaviorRegistry.register(FanControlBehavior);
//# sourceMappingURL=FanControlBehavior.js.map