forked from google-home/smart-home-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
devices.ts
29 lines (24 loc) · 883 Bytes
/
devices.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import jsYaml from "js-yaml";
import { readFileSync } from "fs";
import { join } from "path";
// import { states } from "./states";
// import { traitsConfig } from "./traits";
export function loadDevices() {
const devices = jsYaml.safeLoad(
readFileSync(join(__dirname, "devices.yml"), "utf8")
);
// devices.forEach((d: any) => {
// const { mqtt, traits } = d;
// const { states: mqttStates, commands: mqttCommands } = mqtt;
// console.log(d.id, traits, mqttStates, mqttCommands);
// traits
// .map((trait: string) => trait.replace("action.devices.traits.", ""))
// .forEach((trait: string) => {
// console.log("\n", trait, traitsConfig);
// const conf = (traitsConfig as any)[trait];
// const { state, commands } = conf;
// console.log(d.id, state, commands);
// });
// });
return [...devices];
}