homebridge-smartsystem 6.0.5 → 6.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.0.5",
4
+ "version": "6.0.6",
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
@@ -43,7 +43,7 @@ class Base {
43
43
  this.write(this.type, this.config);
44
44
  }
45
45
  read(type, fname = "") {
46
- const fn = fname || (__dirname + '/../config.' + type + '.json');
46
+ const fn = fname || ("~/.homebridge/config." + type + ".json");
47
47
  let config = null;
48
48
  try {
49
49
  const configBuf = fs.readFileSync(fn);
@@ -61,7 +61,7 @@ class Base {
61
61
  return temp;
62
62
  }
63
63
  write(type, config, fname = "") {
64
- const fn = fname || (__dirname + '/../config.' + type + '.json');
64
+ const fn = fname || ("~/.homebridge/config." + type + ".json");
65
65
  try {
66
66
  config = types_1.Sanitizers[type](config);
67
67
  fs.writeFileSync(fn, JSON.stringify(config, null, 2));
package/server/base.ts CHANGED
@@ -57,7 +57,7 @@ export class Base {
57
57
 
58
58
 
59
59
  read(type: string, fname: string = "") {
60
- const fn = fname || (__dirname + '/../config.' + type + '.json');
60
+ const fn = fname || ("~/.homebridge/config." + type + ".json");
61
61
  let config = null;
62
62
 
63
63
  try {
@@ -78,7 +78,7 @@ export class Base {
78
78
  }
79
79
 
80
80
  write(type: string, config, fname: string = "") {
81
- const fn = fname || (__dirname + '/../config.' + type + '.json');
81
+ const fn = fname || ("~/.homebridge/config." + type + ".json");
82
82
  try {
83
83
  config = Sanitizers[type](config);
84
84
  fs.writeFileSync(fn, JSON.stringify(config, null, 2));
@@ -25,6 +25,9 @@ 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");
28
31
  class Platform extends base_1.Base {
29
32
  constructor(log, config, api) {
30
33
  // set debug to true for new config files
@@ -16,8 +16,11 @@ 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";
19
20
 
20
21
 
22
+ if (! existsSync("~/homebridge")) mkdirSync("~/homebridge");
23
+
21
24
  export class Platform extends Base {
22
25
  homebridgeAPI: API;
23
26
  config: PlatformConfig;