homebridge-foxess 1.0.21 → 1.0.23
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/.github/dependabot.yml +2 -2
- package/.github/workflows/audit.yml +1 -1
- package/.github/workflows/{auto-merge-dependabot.yml → auto-merge.yml} +1 -1
- package/.github/workflows/build.yml +2 -2
- package/.github/workflows/corepack.yml +3 -3
- package/.github/workflows/npm-publish.yml +2 -2
- package/.vscode/launch.json +10 -0
- package/dist/accessories/inverterAccessory.js +12 -15
- package/dist/accessories/inverterAccessory.js.map +1 -1
- package/dist/platform.js +4 -4
- package/dist/platform.js.map +1 -1
- package/package.json +10 -9
- package/src/accessories/inverterAccessory.ts +11 -14
- package/src/platform.ts +6 -6
package/.github/dependabot.yml
CHANGED
|
@@ -10,10 +10,10 @@ updates:
|
|
|
10
10
|
- package-ecosystem: "github-actions"
|
|
11
11
|
directory: "/"
|
|
12
12
|
schedule:
|
|
13
|
-
interval: "
|
|
13
|
+
interval: "monthly"
|
|
14
14
|
|
|
15
15
|
# Maintain dependencies for npm
|
|
16
16
|
- package-ecosystem: "npm"
|
|
17
17
|
directory: "/"
|
|
18
18
|
schedule:
|
|
19
|
-
interval: "
|
|
19
|
+
interval: "monthly"
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
17
|
-
node-version: [18.x, 20.x]
|
|
17
|
+
node-version: [18.x, 20.x, 22.x]
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
20
|
- uses: actions/checkout@v4
|
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
path: node_modules
|
|
25
25
|
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
26
26
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
27
|
-
uses: actions/setup-node@v4.0.
|
|
27
|
+
uses: actions/setup-node@v4.0.3
|
|
28
28
|
with:
|
|
29
29
|
node-version: ${{ matrix.node-version }}
|
|
30
30
|
- uses: pnpm/action-setup@v4
|
|
@@ -25,10 +25,10 @@ jobs:
|
|
|
25
25
|
with:
|
|
26
26
|
path: node_modules
|
|
27
27
|
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.json') }}
|
|
28
|
-
- name: Use Node.js
|
|
29
|
-
uses: actions/setup-node@v4.0.
|
|
28
|
+
- name: Use Node.js 18.x
|
|
29
|
+
uses: actions/setup-node@v4.0.3
|
|
30
30
|
with:
|
|
31
|
-
node-version:
|
|
31
|
+
node-version: 18.x
|
|
32
32
|
- uses: pnpm/action-setup@v4
|
|
33
33
|
- run: corepack up
|
|
34
34
|
- name: Create Pull Request
|
|
@@ -12,7 +12,7 @@ jobs:
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v4
|
|
15
|
-
- uses: actions/setup-node@v4.0.
|
|
15
|
+
- uses: actions/setup-node@v4.0.3
|
|
16
16
|
with:
|
|
17
17
|
node-version: 18
|
|
18
18
|
registry-url: https://registry.npmjs.org/
|
|
@@ -34,7 +34,7 @@ jobs:
|
|
|
34
34
|
with:
|
|
35
35
|
ref: main
|
|
36
36
|
fetch-tags: true
|
|
37
|
-
- uses: actions/setup-node@v4.0.
|
|
37
|
+
- uses: actions/setup-node@v4.0.3
|
|
38
38
|
with:
|
|
39
39
|
node-version: 18
|
|
40
40
|
registry-url: https://registry.npmjs.org/
|
package/.vscode/launch.json
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
"cwd": "${workspaceRoot}",
|
|
11
11
|
"internalConsoleOptions": "openOnSessionStart"
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Homebridge",
|
|
15
|
+
"type": "node",
|
|
16
|
+
"request": "launch",
|
|
17
|
+
"args": ["node_modules/homebridge/bin/homebridge"],
|
|
18
|
+
"runtimeArgs": ["-r", "ts-node/register"],
|
|
19
|
+
"cwd": "${workspaceFolder}",
|
|
20
|
+
"internalConsoleOptions": "openOnSessionStart",
|
|
21
|
+
"preLaunchTask": "npm: debugIde"
|
|
22
|
+
},
|
|
13
23
|
{
|
|
14
24
|
"name": "Main",
|
|
15
25
|
"type": "node",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InverterAccessory = exports.
|
|
3
|
+
exports.InverterAccessory = exports.DisplayNames = void 0;
|
|
4
4
|
const minLightLevel = 0.0001;
|
|
5
|
-
exports.
|
|
5
|
+
exports.DisplayNames = new Map([
|
|
6
6
|
['loadsPower', 'Load Power'],
|
|
7
7
|
['generationPower', 'Output Power'],
|
|
8
|
-
['feedinPower', 'Feed
|
|
8
|
+
['feedinPower', 'Feed in Power'],
|
|
9
9
|
['gridConsumptionPower', 'Grid Consumption Power']
|
|
10
10
|
]);
|
|
11
11
|
class InverterAccessory {
|
|
@@ -33,9 +33,9 @@ class InverterAccessory {
|
|
|
33
33
|
.setCharacteristic(this.platform.Characteristic.SerialNumber, this.inverter.deviceSN)
|
|
34
34
|
.setCharacteristic(this.platform.Characteristic.HardwareRevision, this.inverter.productType);
|
|
35
35
|
configuredServices.push(informationService);
|
|
36
|
-
exports.
|
|
37
|
-
this.platform.log.debug(
|
|
38
|
-
const service = this.accessory.getService(
|
|
36
|
+
exports.DisplayNames.forEach((displayName, variable) => {
|
|
37
|
+
this.platform.log.debug(`Creating light sensor for ${displayName} (${variable})`);
|
|
38
|
+
const service = this.accessory.getService(variable) ?? this.accessory.addService(this.platform.Service.LightSensor, undefined, variable);
|
|
39
39
|
this.values.set(variable, minLightLevel);
|
|
40
40
|
service.setCharacteristic(this.platform.Characteristic.Name, displayName);
|
|
41
41
|
service.setCharacteristic(this.platform.Characteristic.StatusActive, false);
|
|
@@ -55,8 +55,10 @@ class InverterAccessory {
|
|
|
55
55
|
this.accessory.removeService(service);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
setupSwitch(configuredServices,
|
|
59
|
-
|
|
58
|
+
setupSwitch(configuredServices, displayName, variable, handler) {
|
|
59
|
+
this.platform.log.debug(`Creating switch '${displayName}' (${variable})`);
|
|
60
|
+
const service = this.accessory.getService(variable) ?? this.accessory.addService(this.platform.Service.Switch, undefined, variable);
|
|
61
|
+
service.displayName = displayName;
|
|
60
62
|
const characteristic = service.getCharacteristic(this.platform.Characteristic.On);
|
|
61
63
|
characteristic.onSet(this.updateSwitches.bind(this));
|
|
62
64
|
characteristic.onGet(handler.bind(this));
|
|
@@ -78,14 +80,9 @@ class InverterAccessory {
|
|
|
78
80
|
update(value) {
|
|
79
81
|
this.platform.log.debug('Updating', this.accessory.displayName, 'with', value.datas.length, 'value(s)');
|
|
80
82
|
value.datas.forEach((data) => {
|
|
81
|
-
const
|
|
82
|
-
if (serviceName === undefined) {
|
|
83
|
-
this.platform.log.error('Received real-time data for an unknown variable:', data.variable);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const service = this.accessory.getService(serviceName);
|
|
83
|
+
const service = this.accessory.getService(data.variable);
|
|
87
84
|
if (service === undefined) {
|
|
88
|
-
this.platform.log.error('Unable to find service for',
|
|
85
|
+
this.platform.log.error('Unable to find service for', data.variable);
|
|
89
86
|
return;
|
|
90
87
|
}
|
|
91
88
|
const newValue = Math.max(data.value * 1000, minLightLevel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inverterAccessory.js","sourceRoot":"","sources":["../../src/accessories/inverterAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAM,aAAa,GAAG,MAAM,CAAA;AAEf,QAAA,
|
|
1
|
+
{"version":3,"file":"inverterAccessory.js","sourceRoot":"","sources":["../../src/accessories/inverterAccessory.ts"],"names":[],"mappings":";;;AAIA,MAAM,aAAa,GAAG,MAAM,CAAA;AAEf,QAAA,YAAY,GAAwB,IAAI,GAAG,CAAiB;IACvE,CAAC,YAAY,EAAE,YAAY,CA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AAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAA;YAC7F,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,QAAQ,GAAG,aAAa,CAAC,CAAA;QACnG,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;CACF;AA3FD,8CA2FC"}
|
package/dist/platform.js
CHANGED
|
@@ -36,15 +36,15 @@ class FoxESSPlatform {
|
|
|
36
36
|
(async () => {
|
|
37
37
|
try {
|
|
38
38
|
await this.discoverDevices();
|
|
39
|
-
this.log.debug(`Updating every ${this.interval}ms`);
|
|
39
|
+
this.log.debug(`Updating every ${this.interval.toString()}ms`);
|
|
40
40
|
setInterval(this.update.bind(this), this.interval);
|
|
41
41
|
this.update();
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
this.log.error(`Unable to discover. Will retry after ${minInterval}ms`, e);
|
|
44
|
+
this.log.error(`Unable to discover. Will retry after ${minInterval.toString()}ms`, e);
|
|
45
45
|
setTimeout(this.initialise.bind(this), minInterval);
|
|
46
46
|
}
|
|
47
|
-
})().catch((e) => { this.log.error(
|
|
47
|
+
})().catch((e) => { this.log.error('Unable to initialise: ', e); });
|
|
48
48
|
}
|
|
49
49
|
configureAccessory(accessory) {
|
|
50
50
|
this.log.debug('Loading accessory from cache:', accessory.displayName);
|
|
@@ -107,7 +107,7 @@ class FoxESSPlatform {
|
|
|
107
107
|
}
|
|
108
108
|
async updateCurrentLevel() {
|
|
109
109
|
this.log.debug('Fetching real time data');
|
|
110
|
-
const results = await foxess_lib_1.inverter.getRealTimeData(this.apiKey, { variables: Array.from(inverterAccessory_1.
|
|
110
|
+
const results = await foxess_lib_1.inverter.getRealTimeData(this.apiKey, { variables: Array.from(inverterAccessory_1.DisplayNames.keys()) });
|
|
111
111
|
if (results === undefined) {
|
|
112
112
|
this.log.warn('No results came through.');
|
|
113
113
|
return;
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AACvD,uEAAiF;AAEjF,2CAAqC;AAErC,MAAM,WAAW,GAAW,EAAE,GAAG,IAAI,CAAA;AAErC,MAAa,cAAc;IAaP;IACA;IACA;IAdF,MAAM,CAAQ;IACb,QAAQ,CAAQ;IAChB,UAAU,CAAwB;IAC3C,SAAS,GAAG,CAAC,CAAA;IACL,OAAO,CAAgB;IACvB,cAAc,CAAuB;IACpC,SAAS,GAAmC,IAAI,GAAG,EAA6B,CAAA;IAGjF,WAAW,GAAwB,EAAE,CAAA;IAErD,YACkB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QAExB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAA;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAA;QACjD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACnC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC,CAAC,MAAM,CAAC,UAAwB,CAAC,CAAC,CAAC,SAAS,CAAA;QAClG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE,WAAW,CA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;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;gBAC5C,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACzB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AA3HD,wCA2HC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-foxess",
|
|
3
3
|
"displayName": "Homebridge FoxESS",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"description": "Basic utility accessories for displaying solar FoxESS solar information in Homebridge: https://github.com/nfarina/homebridge",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -27,26 +27,27 @@
|
|
|
27
27
|
"main": "dist/index.js",
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=18.0.0",
|
|
30
|
-
"homebridge": ">=1.7.0"
|
|
30
|
+
"homebridge": ">=1.7.0 || ^2.0.0-beta.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@stylistic/eslint-plugin": "^2.1.0",
|
|
34
|
-
"@types/node": "^
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
36
|
-
"homebridge": "^1.8.
|
|
37
|
-
"rimraf": "^
|
|
36
|
+
"homebridge": "^1.8.2",
|
|
37
|
+
"rimraf": "^6.0.1",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
39
|
"typescript": "^5.4.5",
|
|
40
|
-
"typescript-eslint": "^7.
|
|
40
|
+
"typescript-eslint": "^7.13.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"foxess-lib": "^0.
|
|
43
|
+
"foxess-lib": "^0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"forceClean": "rimraf ./dist",
|
|
47
47
|
"build": "tsc",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
48
|
+
"debugIde": "pnpm build && pnpm link .",
|
|
49
|
+
"lint": "pnpm eslint --max-warnings=0 src",
|
|
50
|
+
"lintAndFix": "eslint --fix --max-warnings=0 src",
|
|
50
51
|
"debug": "pnpm build && homebridge -I -D -P ."
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -4,10 +4,10 @@ import type { Indicators } from '../indicators'
|
|
|
4
4
|
import { inverter } from 'foxess-lib'
|
|
5
5
|
const minLightLevel = 0.0001
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const DisplayNames: Map<string, string> = new Map<string, string>([
|
|
8
8
|
['loadsPower', 'Load Power'], // Load Power (kW); House usage.
|
|
9
9
|
['generationPower', 'Output Power'], // Output Power (kW); Solar generation.
|
|
10
|
-
['feedinPower', 'Feed
|
|
10
|
+
['feedinPower', 'Feed in Power'], // Feed-in Power (kW); Exported power.
|
|
11
11
|
['gridConsumptionPower', 'Grid Consumption Power'] // GridConsumption Power (kW); Imported power.
|
|
12
12
|
])
|
|
13
13
|
|
|
@@ -35,9 +35,9 @@ export class InverterAccessory {
|
|
|
35
35
|
|
|
36
36
|
configuredServices.push(informationService)
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
this.platform.log.debug(
|
|
40
|
-
const service = this.accessory.getService(
|
|
38
|
+
DisplayNames.forEach((displayName, variable) => {
|
|
39
|
+
this.platform.log.debug(`Creating light sensor for ${displayName} (${variable})`)
|
|
40
|
+
const service = this.accessory.getService(variable) ?? this.accessory.addService(this.platform.Service.LightSensor, undefined, variable)
|
|
41
41
|
this.values.set(variable, minLightLevel)
|
|
42
42
|
service.setCharacteristic(this.platform.Characteristic.Name, displayName)
|
|
43
43
|
service.setCharacteristic(this.platform.Characteristic.StatusActive, false)
|
|
@@ -60,8 +60,10 @@ export class InverterAccessory {
|
|
|
60
60
|
})
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
private setupSwitch(configuredServices: Service[],
|
|
64
|
-
|
|
63
|
+
private setupSwitch(configuredServices: Service[], displayName: string, variable: string, handler: CharacteristicGetHandler): Characteristic {
|
|
64
|
+
this.platform.log.debug(`Creating switch '${displayName}' (${variable})`)
|
|
65
|
+
const service = this.accessory.getService(variable) ?? this.accessory.addService(this.platform.Service.Switch, undefined, variable)
|
|
66
|
+
service.displayName = displayName
|
|
65
67
|
const characteristic = service.getCharacteristic(this.platform.Characteristic.On)
|
|
66
68
|
characteristic.onSet(this.updateSwitches.bind(this))
|
|
67
69
|
characteristic.onGet(handler.bind(this))
|
|
@@ -86,14 +88,9 @@ export class InverterAccessory {
|
|
|
86
88
|
public update(value: inverter.RealTimeData): void {
|
|
87
89
|
this.platform.log.debug('Updating', this.accessory.displayName, 'with', value.datas.length, 'value(s)')
|
|
88
90
|
value.datas.forEach((data) => {
|
|
89
|
-
const
|
|
90
|
-
if (serviceName === undefined) {
|
|
91
|
-
this.platform.log.error('Received real-time data for an unknown variable:', data.variable)
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
const service = this.accessory.getService(serviceName)
|
|
91
|
+
const service = this.accessory.getService(data.variable)
|
|
95
92
|
if (service === undefined) {
|
|
96
|
-
this.platform.log.error('Unable to find service for',
|
|
93
|
+
this.platform.log.error('Unable to find service for', data.variable)
|
|
97
94
|
return
|
|
98
95
|
}
|
|
99
96
|
const newValue = Math.max(data.value * 1000, minLightLevel)
|
package/src/platform.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type API, type DynamicPlatformPlugin, type Logger, type PlatformAccessory, type PlatformConfig, type Service, type Characteristic } from 'homebridge'
|
|
2
2
|
import { PLATFORM_NAME, PLUGIN_NAME } from './settings'
|
|
3
|
-
import { InverterAccessory,
|
|
3
|
+
import { InverterAccessory, DisplayNames } from './accessories/inverterAccessory'
|
|
4
4
|
import { type Indicators } from './indicators'
|
|
5
5
|
import { inverter } from 'foxess-lib'
|
|
6
6
|
|
|
@@ -39,14 +39,14 @@ export class FoxESSPlatform implements DynamicPlatformPlugin {
|
|
|
39
39
|
(async () => {
|
|
40
40
|
try {
|
|
41
41
|
await this.discoverDevices()
|
|
42
|
-
this.log.debug(`Updating every ${this.interval}ms`)
|
|
42
|
+
this.log.debug(`Updating every ${this.interval.toString()}ms`)
|
|
43
43
|
setInterval(this.update.bind(this), this.interval)
|
|
44
44
|
this.update()
|
|
45
45
|
} catch (e) {
|
|
46
|
-
this.log.error(`Unable to discover. Will retry after ${minInterval}ms`, e)
|
|
46
|
+
this.log.error(`Unable to discover. Will retry after ${minInterval.toString()}ms`, e)
|
|
47
47
|
setTimeout(this.initialise.bind(this), minInterval)
|
|
48
48
|
}
|
|
49
|
-
})().catch((e) => { this.log.error(
|
|
49
|
+
})().catch((e: unknown) => { this.log.error('Unable to initialise: ', e) })
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
configureAccessory(accessory: PlatformAccessory): void {
|
|
@@ -101,7 +101,7 @@ export class FoxESSPlatform implements DynamicPlatformPlugin {
|
|
|
101
101
|
update(): void {
|
|
102
102
|
this.updateCurrentLevel()
|
|
103
103
|
.then(() => { this.failCount = 0 })
|
|
104
|
-
.catch((e) => {
|
|
104
|
+
.catch((e: unknown) => {
|
|
105
105
|
const message = 'Unable to update levels:'
|
|
106
106
|
if (++this.failCount < 10) {
|
|
107
107
|
this.log.warn(message, e)
|
|
@@ -113,7 +113,7 @@ export class FoxESSPlatform implements DynamicPlatformPlugin {
|
|
|
113
113
|
|
|
114
114
|
async updateCurrentLevel(): Promise<void> {
|
|
115
115
|
this.log.debug('Fetching real time data')
|
|
116
|
-
const results = await inverter.getRealTimeData(this.apiKey, { variables: Array.from(
|
|
116
|
+
const results = await inverter.getRealTimeData(this.apiKey, { variables: Array.from(DisplayNames.keys()) })
|
|
117
117
|
if (results === undefined) {
|
|
118
118
|
this.log.warn('No results came through.')
|
|
119
119
|
return
|