homebridge-smartsystem 6.4.3 → 6.4.5

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/README.md CHANGED
@@ -285,7 +285,7 @@ Homebridge UI version
285
285
  ### v6.4.x - 28-11-2022 - Binding to registers
286
286
  - 0: writing to registers
287
287
  - 1: ask/show protocol version -> publish
288
- - 2: test on firmware version, not protocol for using registers, due to bug in master firmware pre v101.x
288
+ - 2 & 3: test on protocol version, not firmware for using registers, due to bug in master firmware pre v101.x
289
289
 
290
290
  ## Hardware
291
291
  A Raspberry Pi that connects to a Duotecno IP Node
package/config.json CHANGED
@@ -167,10 +167,13 @@
167
167
  }
168
168
  ]
169
169
  },
170
+ "socapp": {
171
+ "debug": true,
172
+ "port": 9999
173
+ },
170
174
  "smartapp": {
171
175
  "apiPort": 8581,
172
176
  "apiHost": "192.168.0.99",
173
- "socapp": false,
174
177
  "port": 5002,
175
178
  "switches": [
176
179
  {
@@ -412,7 +412,7 @@ class Master extends base_1.Base {
412
412
  this.resolveLogin = null;
413
413
  // if logged in, ask protocol version
414
414
  if (this.isLoggedIn) {
415
- this.send(protocol_1.Protocol.buildRequestNodeMgt(protocol_1.reqNodeAttributes.nodeVersion));
415
+ this.send(protocol_1.Protocol.buildRequestNodeMgt(protocol_1.reqNodeAttributes.nodeProtocol));
416
416
  }
417
417
  }
418
418
  else {
@@ -751,12 +751,12 @@ class Master extends base_1.Base {
751
751
  }
752
752
  requestRegisterValue(register) {
753
753
  return __awaiter(this, void 0, void 0, function* () {
754
- if (this.version >= 6609) {
754
+ if (this.protocol >= 209) {
755
755
  yield this.send(protocol_1.Protocol.buildRegister(register));
756
756
  this.info("request register: " + register);
757
757
  }
758
758
  else {
759
- this.err("FC_REGISTERMAP not available before firmware v66.09");
759
+ this.err("FC_REGISTERMAP not available before protocol v2.09");
760
760
  }
761
761
  });
762
762
  }
@@ -773,12 +773,12 @@ class Master extends base_1.Base {
773
773
  }
774
774
  setRegisterValue(register, value) {
775
775
  return __awaiter(this, void 0, void 0, function* () {
776
- if (this.version >= 6609) {
776
+ if (this.protocol >= 209) {
777
777
  yield this.send(protocol_1.Protocol.buildRegister(register, value));
778
778
  this.info("set register: " + register + ", to: " + value);
779
779
  }
780
780
  else {
781
- this.err("FC_REGISTERMAP not available before firmware v66.09");
781
+ this.err("FC_REGISTERMAP not available before protocol v2.09");
782
782
  }
783
783
  });
784
784
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-smartsystem",
3
3
  "displayname": "Duotecno Bridge",
4
- "version": "6.4.3",
4
+ "version": "6.4.5",
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",
@@ -92,11 +92,11 @@ class Platform extends base_1.Base {
92
92
  else {
93
93
  (0, logger_1.log)("homebridge", "platform - No SmartApp configured.");
94
94
  }
95
- // startup a SocApp if configured -> for proxy (not needed)
95
+ // startup a SocApp if configured -> for proxy (not needed for normal operations)
96
96
  if (this.config.socapp) {
97
97
  try {
98
98
  // reuse the config file from the smartapp
99
- this.smartsoc = new socapp_1.SocApp(this.system, 'smartapp');
99
+ this.smartsoc = new socapp_1.SocApp(this.system, 'socapp');
100
100
  this.smartsoc.serve();
101
101
  }
102
102
  catch (err) {
@@ -99,11 +99,11 @@ export class Platform extends Base {
99
99
  log("homebridge", "platform - No SmartApp configured.");
100
100
  }
101
101
 
102
- // startup a SocApp if configured -> for proxy (not needed)
102
+ // startup a SocApp if configured -> for proxy (not needed for normal operations)
103
103
  if (this.config.socapp) {
104
104
  try {
105
105
  // reuse the config file from the smartapp
106
- this.smartsoc = new SocApp(this.system, 'smartapp');
106
+ this.smartsoc = new SocApp(this.system, 'socapp');
107
107
  this.smartsoc.serve();
108
108
 
109
109
  } catch(err) {
package/server/socapp.js CHANGED
@@ -26,11 +26,14 @@ class SocApp extends webapp_1.WebApp {
26
26
  // hashmap with all connected clients
27
27
  this.clients = {};
28
28
  if (this.config.debug)
29
- logger_1.logSettings["proxy"] = logger_1.LogLevel.debug;
29
+ logger_1.logSettings["socapp"] = logger_1.LogLevel.debug;
30
30
  this.port = port || this.config.port || this.port || 80;
31
31
  this.system = system;
32
32
  this.support = new support_1.Support(system);
33
33
  }
34
+ needsLogin(context) {
35
+ return false;
36
+ }
34
37
  doRequest(context) {
35
38
  return __awaiter(this, void 0, void 0, function* () {
36
39
  if (context.request === "") {
@@ -53,7 +56,7 @@ class SocApp extends webapp_1.WebApp {
53
56
  return this.serveFile(context, context.path);
54
57
  }
55
58
  catch (error) {
56
- (0, logger_1.err)("proxy", "Error serving URL: " + context.req.url);
59
+ (0, logger_1.err)("socapp", "Error serving URL: " + context.req.url);
57
60
  return this.serveFile(context, "/index.html");
58
61
  // return this.notFound(context.req.url);
59
62
  }
@@ -61,7 +64,7 @@ class SocApp extends webapp_1.WebApp {
61
64
  });
62
65
  }
63
66
  serve() {
64
- (0, logger_1.log)("proxy", "SocApp - Start http server on port " + this.port);
67
+ (0, logger_1.log)("socapp", "SocApp - Start http server on port " + this.port);
65
68
  super.serve(() => {
66
69
  const wsServer = new ws_1.Server({ server: this.server });
67
70
  wsServer.on('connection', this.handleClient.bind(this));
@@ -71,7 +74,7 @@ class SocApp extends webapp_1.WebApp {
71
74
  var _a, _b;
72
75
  const data = fs.readFileSync("www" + fn);
73
76
  const type = mime.lookup(fn) || "application/text";
74
- (0, logger_1.log)("proxy", "Serve - " + (((_b = (_a = context.req) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) || "no-remote") + ": " + fn + " - " + type);
77
+ (0, logger_1.log)("socapp", "Serve - " + (((_b = (_a = context.req) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) || "no-remote") + ": " + fn + " - " + type);
75
78
  return { status: 200, data, type };
76
79
  }
77
80
  renderLog() {
@@ -96,9 +99,9 @@ class SocApp extends webapp_1.WebApp {
96
99
  handleClient(client, req) {
97
100
  let target;
98
101
  const clientAddr = client._socket.remoteAddress;
99
- const logger = (msg) => (0, logger_1.log)('proxy', clientAddr + ': ' + msg);
102
+ const logger = (msg) => (0, logger_1.log)('socapp', clientAddr + ': ' + msg);
100
103
  const info = (this.config.debug) ?
101
- (msg) => logger('Proxy - ' + clientAddr + ': ' + msg) :
104
+ (msg) => logger('socapp - ' + clientAddr + ': ' + msg) :
102
105
  (msg) => null;
103
106
  /////////////////////////////////////
104
107
  // url parsing to find ip and port //
package/server/socapp.ts CHANGED
@@ -3,7 +3,6 @@ import * as mime from 'mime-types';
3
3
  import * as net from 'net';
4
4
  import { Server as WSServer } from 'ws';
5
5
  import { System } from '../duotecno/system';
6
- import { LogFunction } from '../duotecno/types';
7
6
  import { log, logSettings, LogLevel, err } from "../duotecno/logger";
8
7
  import { Support } from './support';
9
8
  import { Context, HttpResponse, WebApp } from "./webapp";
@@ -21,7 +20,7 @@ export class SocApp extends WebApp {
21
20
 
22
21
  constructor(system: System, type: string, port?: number) {
23
22
  super(type);
24
- if (this.config.debug) logSettings["proxy"] = LogLevel.debug;
23
+ if (this.config.debug) logSettings["socapp"] = LogLevel.debug;
25
24
 
26
25
  this.port = port || this.config.port || this.port || 80;
27
26
 
@@ -29,6 +28,10 @@ export class SocApp extends WebApp {
29
28
  this.support = new Support(system);
30
29
  }
31
30
 
31
+ needsLogin(context: Context): boolean {
32
+ return false;
33
+ }
34
+
32
35
  async doRequest(context: Context): Promise<HttpResponse> {
33
36
  if (context.request === "") {
34
37
  return this.serveFile(context, "/index.html");
@@ -50,7 +53,7 @@ export class SocApp extends WebApp {
50
53
  return this.serveFile(context, context.path);
51
54
 
52
55
  } catch(error) {
53
- err("proxy", "Error serving URL: " + context.req.url);
56
+ err("socapp", "Error serving URL: " + context.req.url);
54
57
  return this.serveFile(context, "/index.html");
55
58
  // return this.notFound(context.req.url);
56
59
  }
@@ -58,7 +61,7 @@ export class SocApp extends WebApp {
58
61
  }
59
62
 
60
63
  serve() {
61
- log("proxy", "SocApp - Start http server on port " + this.port);
64
+ log("socapp", "SocApp - Start http server on port " + this.port);
62
65
  super.serve(() => {
63
66
  const wsServer = new WSServer({server: this.server});
64
67
  wsServer.on('connection', this.handleClient.bind(this));
@@ -68,7 +71,7 @@ export class SocApp extends WebApp {
68
71
  serveFile(context: Context, fn: string): HttpResponse {
69
72
  const data = fs.readFileSync("www"+fn);
70
73
  const type = mime.lookup(fn) || "application/text";
71
- log("proxy", "Serve - " + (context.req?.socket?.remoteAddress || "no-remote") + ": " + fn + " - " + type);
74
+ log("socapp", "Serve - " + (context.req?.socket?.remoteAddress || "no-remote") + ": " + fn + " - " + type);
72
75
  return { status: 200, data, type };
73
76
  }
74
77
 
@@ -97,9 +100,9 @@ export class SocApp extends WebApp {
97
100
  handleClient(client, req) {
98
101
  let target: net.Socket;
99
102
  const clientAddr = client._socket.remoteAddress;
100
- const logger = (msg) => log('proxy', clientAddr + ': '+ msg);
103
+ const logger = (msg) => log('socapp', clientAddr + ': '+ msg);
101
104
  const info = (this.config.debug) ?
102
- (msg) => logger('Proxy - ' + clientAddr + ': '+ msg) :
105
+ (msg) => logger('socapp - ' + clientAddr + ': '+ msg) :
103
106
  (msg) => null;
104
107
 
105
108
  /////////////////////////////////////
package/server/somfy.js CHANGED
@@ -172,7 +172,7 @@ setup().then(() => {
172
172
  busy = false;
173
173
  }).catch((e) => {
174
174
  (0, logger_1.debug)("somfy", "gpio package not initialized");
175
- if (e.code != "EACCES")
175
+ if ((e.code != "EACCES") && (e.code != "ENOENT"))
176
176
  (0, logger_1.debug)("somfy", e);
177
177
  init = false;
178
178
  busy = false;
package/www/index.html ADDED
@@ -0,0 +1,3 @@
1
+ <html>
2
+ <h1>Hello world. Please leave me alone</h1>
3
+ </html>