forked from ricott/sma.modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (28 loc) · 844 Bytes
/
app.js
File metadata and controls
33 lines (28 loc) · 844 Bytes
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
30
31
32
33
"use strict";
const { App } = require('homey');
const { Log } = require('homey-log');
class SmaModbusApp extends App {
async onInit() {
this.homeyLog = new Log({ homey: this.homey });
if (process.env.DEBUG == '1') {
require('inspector').open(9222, '0.0.0.0', true);
}
this.setupGlobalFetch();
this.log('Initializing SMA Modbus app ...');
}
setupGlobalFetch() {
if (!global.fetch) {
global.fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
}
if (!global.AbortSignal.timeout) {
global.AbortSignal.timeout = timeout => {
const controller = new AbortController();
const abort = setTimeout(() => {
controller.abort();
}, timeout);
return controller.signal;
}
}
}
}
module.exports = SmaModbusApp;