homebridge-gsh-kazari
Version:
68 lines (62 loc) • 2.12 kB
JavaScript
;
exports.__esModule = true;
var fs = require("fs");
var path = require("path");
var hap_nodejs_1 = require("hap-nodejs");
/** Generate Service Types */
/*
var Services = [
'export const Services = {',
];
// console.log(hap_nodejs_1.Service);
for (var _i = 0, _a = Object.entries(hap_nodejs_1.Service); _i < _a.length; _i++) {
var _b = _a[_i], name_1 = _b[0], value = _b[1];
if (value.UUID) {
Services.push(" '" + value.UUID + "': '" + name_1 + "',");
Services.push(" '" + name_1 + "': '" + value.UUID + "',");
}
}
Services.push("};\n\n");
Services = Services.join('\n');
*/
/** Generate Characteristic Types */
var Characteristics = [
'exports.Characteristics = {',
];
// console.log(hap_nodejs_1.Characteristic);
for (var _c = 0, _d = Object.entries(hap_nodejs_1.Characteristic); _c < _d.length; _c++) {
var _e = _d[_c], name_2 = _e[0], value = _e[1];
if (value.UUID) {
// console.log('A -> ', _e[1]);
var func = _e[1];
func.prototype.setProps = function () {
}
this.setProps = function () {
}
this.getDefaultValue = function () {
}
var obj = func.call(this);
// console.log('D -> %s: %s', value.UUID, obj.displayName);
// Characteristics.push(" '" + value.UUID + "': '" + name_2 + "',");
Characteristics.push(" '" + value.UUID + "': '" + obj.displayName + "',");
// Characteristics.push(" '" + name_2 + "': '" + value.UUID + "',");
}
}
Characteristics.push("};\n\n");
Characteristics = Characteristics.join('\n');
/** Generate Category Types */
/*
var Category = [
'export const Categories = {',
];
for (var _f = 0, _g = Object.entries(hap_nodejs_1.Categories); _f < _g.length; _f++) {
var _h = _g[_f], name_3 = _h[0], value = _h[1];
if (typeof value === 'number') {
Category.push(" '" + name_3 + "': " + value + ",");
}
}
Category.push("};\n");
Category = Category.join('\n');
*/
var out = "/* This file is automatically generated */\n\n" + Characteristics;
fs.writeFileSync(path.resolve(__dirname, '../lib/hap-types.js'), out, 'utf8');