homebridge-smartsystem 6.0.6 → 6.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/base.js +8 -2
- package/server/base.ts +10 -2
- package/server/platform.js +1 -3
- package/server/platform.ts +2 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-smartsystem",
|
|
3
3
|
"displayname": "Duotecno Bridge",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.7",
|
|
5
5
|
"description": "SmartServer (Proxy Websockets to TCP sockets, Smappee MQTT, Duotecno IP Nodes, Homekit interface)",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"author": "Johan Coppieters",
|
package/server/base.js
CHANGED
|
@@ -4,11 +4,17 @@ exports.Base = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const protocol_1 = require("../duotecno/protocol");
|
|
6
6
|
const types_1 = require("../duotecno/types");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const os_1 = require("os");
|
|
9
|
+
const kConfigFiles = (0, os_1.homedir)() + "/homebridge";
|
|
10
|
+
if (!(0, fs_1.existsSync)(kConfigFiles))
|
|
11
|
+
(0, fs_1.mkdirSync)(kConfigFiles);
|
|
7
12
|
///////////////
|
|
8
13
|
// Log Class //
|
|
9
14
|
///////////////
|
|
10
15
|
class Base {
|
|
11
16
|
constructor(type, logger, config) {
|
|
17
|
+
this.configFiles = kConfigFiles;
|
|
12
18
|
this.type = type || "base";
|
|
13
19
|
this.logger = console.log; // logger || console.log;
|
|
14
20
|
if (config)
|
|
@@ -43,7 +49,7 @@ class Base {
|
|
|
43
49
|
this.write(this.type, this.config);
|
|
44
50
|
}
|
|
45
51
|
read(type, fname = "") {
|
|
46
|
-
const fn = fname || ("
|
|
52
|
+
const fn = fname || (this.configFiles + "/config." + type + ".json");
|
|
47
53
|
let config = null;
|
|
48
54
|
try {
|
|
49
55
|
const configBuf = fs.readFileSync(fn);
|
|
@@ -61,7 +67,7 @@ class Base {
|
|
|
61
67
|
return temp;
|
|
62
68
|
}
|
|
63
69
|
write(type, config, fname = "") {
|
|
64
|
-
const fn = fname || ("
|
|
70
|
+
const fn = fname || (this.configFiles + "/config." + type + ".json");
|
|
65
71
|
try {
|
|
66
72
|
config = types_1.Sanitizers[type](config);
|
|
67
73
|
fs.writeFileSync(fn, JSON.stringify(config, null, 2));
|
package/server/base.ts
CHANGED
|
@@ -3,6 +3,13 @@ import { Protocol } from "../duotecno/protocol";
|
|
|
3
3
|
import { LogFunction, now, Sanitizers } from "../duotecno/types";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
import { existsSync, mkdirSync } from "fs";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
|
|
9
|
+
const kConfigFiles = homedir() + "/homebridge";
|
|
10
|
+
if (! existsSync(kConfigFiles)) mkdirSync(kConfigFiles);
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
///////////////
|
|
7
14
|
// Log Class //
|
|
8
15
|
///////////////
|
|
@@ -12,6 +19,7 @@ export class Base {
|
|
|
12
19
|
debug: boolean;
|
|
13
20
|
logger: LogFunction;
|
|
14
21
|
config: any;
|
|
22
|
+
configFiles = kConfigFiles;
|
|
15
23
|
|
|
16
24
|
constructor(type: string, logger?: LogFunction, config?) {
|
|
17
25
|
this.type = type || "base";
|
|
@@ -57,7 +65,7 @@ export class Base {
|
|
|
57
65
|
|
|
58
66
|
|
|
59
67
|
read(type: string, fname: string = "") {
|
|
60
|
-
const fn = fname || ("
|
|
68
|
+
const fn = fname || (this.configFiles + "/config." + type + ".json");
|
|
61
69
|
let config = null;
|
|
62
70
|
|
|
63
71
|
try {
|
|
@@ -78,7 +86,7 @@ export class Base {
|
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
write(type: string, config, fname: string = "") {
|
|
81
|
-
const fn = fname || ("
|
|
89
|
+
const fn = fname || (this.configFiles + "/config." + type + ".json");
|
|
82
90
|
try {
|
|
83
91
|
config = Sanitizers[type](config);
|
|
84
92
|
fs.writeFileSync(fn, JSON.stringify(config, null, 2));
|
package/server/platform.js
CHANGED
|
@@ -25,9 +25,6 @@ const base_1 = require("./base");
|
|
|
25
25
|
const socapp_1 = require("./socapp");
|
|
26
26
|
const door_1 = require("../accessories/door");
|
|
27
27
|
const lock_1 = require("../accessories/lock");
|
|
28
|
-
const fs_1 = require("fs");
|
|
29
|
-
if (!(0, fs_1.existsSync)("~/homebridge"))
|
|
30
|
-
(0, fs_1.mkdirSync)("~/homebridge");
|
|
31
28
|
class Platform extends base_1.Base {
|
|
32
29
|
constructor(log, config, api) {
|
|
33
30
|
// set debug to true for new config files
|
|
@@ -38,6 +35,7 @@ class Platform extends base_1.Base {
|
|
|
38
35
|
this.config = Object.assign({}, config);
|
|
39
36
|
this.config.debug = (config && ("debug" in config)) ? config.debug : false;
|
|
40
37
|
this.log("running in " + ((this.config.debug) ? "debug" : "prod") + " mode in directory: " + process.cwd());
|
|
38
|
+
this.log("config files in " + this.configFiles + "/config.xxx.json");
|
|
41
39
|
this.log("with config:" + JSON.stringify(config, null, 2));
|
|
42
40
|
// this.log("homebridge object:", api);
|
|
43
41
|
this.homebridgeAPI = api;
|
package/server/platform.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformConfig, UnitExtendedType } from "../duotecno/types";
|
|
2
2
|
import { API, Logger } from "homebridge";
|
|
3
3
|
import { System } from "../duotecno/system";
|
|
4
4
|
import { Smappee } from "./smappee";
|
|
@@ -16,11 +16,8 @@ import { Accessory } from "../accessories/accessory";
|
|
|
16
16
|
import { SocApp } from "./socapp";
|
|
17
17
|
import { Door } from "../accessories/door";
|
|
18
18
|
import { Lock } from "../accessories/lock";
|
|
19
|
-
import { existsSync, mkdirSync } from "fs";
|
|
20
19
|
|
|
21
20
|
|
|
22
|
-
if (! existsSync("~/homebridge")) mkdirSync("~/homebridge");
|
|
23
|
-
|
|
24
21
|
export class Platform extends Base {
|
|
25
22
|
homebridgeAPI: API;
|
|
26
23
|
config: PlatformConfig;
|
|
@@ -40,6 +37,7 @@ export class Platform extends Base {
|
|
|
40
37
|
this.config.debug = (config && ("debug" in config)) ? config.debug : false;
|
|
41
38
|
|
|
42
39
|
this.log("running in " + ((this.config.debug) ? "debug" : "prod") + " mode in directory: " + process.cwd());
|
|
40
|
+
this.log("config files in " + this.configFiles + "/config.xxx.json");
|
|
43
41
|
this.log("with config:" + JSON.stringify(config, null, 2));
|
|
44
42
|
// this.log("homebridge object:", api);
|
|
45
43
|
|