@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
192 lines (185 loc) • 4.45 kB
text/typescript
//import InsteonMap from "./Insteon.json";
import { CarbonMonoxideConcentrationMeasurement } from '@matter/main/clusters';
import { CarbonMonoxideConcentrationMeasurementServer } from '@matter/node/behaviors';
import { ContactSensorDevice, DimmableLightDevice, DoorLockDevice, FanDevice, OnOffLightDevice, OnOffLightSwitchDevice, OnOffPlugInUnitDevice, SmokeCoAlarmDevice, WaterLeakDetectorDevice } from '@matter/node/devices';
import type { COSensor } from 'isy-nodejs/Devices/Insteon/COSensor';
import { add, MappingRegistry, type EndpointMapping } from './MappingRegistry.js';
//Family: Family.Insteon,
//@ts-ignore
let map = add({ Family: 'Insteon' })
.add({
DoorWindowSensor: {
deviceType: ContactSensorDevice,
mapping: {
booleanState: {
attributes: {
stateValue: { driver: 'open.status', converter: (value) => (value ?? 0) > 0 }
}
},
booleanStateConfiguration: {
attributes: {
sensorFault: { driver: 'open.responding', converter: (value) => (value ?? 1) > 0 }
}
}
}
}
})
.add({
//@ts-ignore
RelayLamp: {
deviceType: OnOffLightDevice,
mapping: {
onOff: {
attributes: {
onOff: { driver: 'status', converter: 'Percent.Boolean' }
},
commands: { on: 'on' }
}
}
}
})
.add({
RelayLampSwitch: {
deviceType: OnOffLightSwitchDevice,
mapping: {
onOff: {
attributes: {
onOff: { driver: 'status', converter: 'Percent.Boolean' }
},
commands: { on: 'on' }
}
}
}
})
.add({
LeakSensor: {
deviceType: WaterLeakDetectorDevice,
mapping: {
booleanState: {
attributes: {
stateValue: { driver: 'wet.status', converter: 'Percent.Boolean' }
}
}
}
}
})
.add({
OnOffOutlet: {
deviceType: OnOffPlugInUnitDevice,
mapping: {
onOff: {
attributes: {
onOff: { driver: 'top.status', converter: 'Percent.Boolean' }
}
}
}
}
})
.add({
COSensor: {
deviceType: SmokeCoAlarmDevice,
mapping: {
smokeCoAlarm: {
attributes: {
expressedState: { driver: 'sensor.status', converter: 'Percent.Boolean' }
}
}
}
}
})
.add({
DimmerLamp: {
deviceType: DimmableLightDevice,
mapping: {
onOff: {
attributes: {
onOff: { driver: 'status', converter: 'Percent.Boolean' }
},
commands: { on: 'on' }
},
levelControl: {
attributes: {
currentLevel: { driver: 'status', converter: 'Percent.LightingLevel' },
onLevel: { driver: 'onLevel', converter: 'Percent.LightingLevel' },
onOffTransitionTime: { driver: 'rampRate', converter: 'RampRate.Deciseconds' }
},
commands: { moveToLevel: 'on' }
}
}
}
})
/*.add({
DimmerOutlet: {
deviceType: DimmerLight,
mapping: {
onOff: {
attributes: {
onOff: { driver: 'status', converter: 'Percent.Boolean' }
},
commands: { on: 'on' }
},
levelControl: {
attributes: {
currentLevel: { driver: 'status', converter: 'Percent.LightingLevel' },
//startUpCurrentLevel: { driver: 'OL', converter: 'Percent.LightingLevel' },
onLevel: { driver: 'onLevel', converter: 'Percent.LightingLevel' }
},
commands: { moveToLevel: { command: 'on' } }
}
}
}
})*/
//@ts-ignore
.add({
Fan: {
//@ts-ignore
deviceType: FanDevice,
// @ts-ignore
mapping: {
fanControl: {
attributes: {
fanMode: { driver: 'motor.status', converter: 'FanLevel.FanMode' },
percentCurrent: { driver: 'motor.status' },
percentSetting: { driver: 'motor.status' }
}
}
}
}
})
.add({
DoorLock: {
deviceType: DoorLockDevice,
mapping: {
doorLock: {
attributes: {
lockState: { driver: 'status', converter: 'InsteonLock.LockState' }
}
}
}
}
});
/*let newMap = add(map, Insteon.DimmerLamp.Node, {
deviceType: DimmableLightDevice,
// @ts-ignore
mapping: {
// @ts-ignore
OnOff: {
attributes: {
onOff: { driver: 'ST', converter: 'Percent.Boolean' ,
},
commands: { on: 'DON' }
},
//@ts-ignore
LevelControl: {
// @ts-ignore
attributes: {
currentLevel: { driver: 'ST', converter: 'Percent.LightingLevel' },
startUpCurrentLevel: { driver: 'OL', converter: 'Percent.LightingLevel' },
onLevel: { driver: 'OL', converter: 'Percent.LightingLevel' }
},
commands: { setLevel: { command: 'DON' } }
}
}
}});*/
//@ts-ignore
MappingRegistry.register(map);