@pmouli/isy-matter-server
Version:
Service to expose an ISY device as a Matter Border router
34 lines (26 loc) • 667 B
text/typescript
import type { Family, UnitOfMeasure } from '../../Definitions/Global/index.js';
interface EventMaps {
$comment: string;
eventMap: EventMap;
}
interface EventMap {
uomMap: UomMap;
id: string;
}
interface UomMap {
uom: {
from: UnitOfMeasure;
to: UnitOfMeasure;
prec?: number;
}[];
$comment: string[];
}
export const UOMMap: Map<Family, { [x in UnitOfMeasure]?: UnitOfMeasure }> = new Map();
export function buildUOMMap<T extends Family>(eventMaps: UomMap, family: T) {
let map: { [x in UnitOfMeasure]?: UnitOfMeasure } = {};
for (const uom of eventMaps.uom) {
map[uom.to] = uom.from as UnitOfMeasure;
}
UOMMap.set(family, map);
return map;
}