homebridge-envoy-solar-sensor 0.1.6 → 0.1.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/config.schema.json +14 -0
- package/index.js +33 -0
- package/package.json +1 -1
package/config.schema.json
CHANGED
|
@@ -74,6 +74,20 @@
|
|
|
74
74
|
"type": "string",
|
|
75
75
|
"default": "",
|
|
76
76
|
"description": "Bearer token from Enphase Entrez, paste token only without the word Bearer"
|
|
77
|
+
},
|
|
78
|
+
"debugLogging": {
|
|
79
|
+
"title": "Debug Logging",
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"default": false,
|
|
82
|
+
"description": "Log production watts on every poll"
|
|
83
|
+
},
|
|
84
|
+
"debugBurstCount": {
|
|
85
|
+
"title": "Debug Burst Count",
|
|
86
|
+
"type": "integer",
|
|
87
|
+
"default": 0,
|
|
88
|
+
"minimum": 0,
|
|
89
|
+
"maximum": 200,
|
|
90
|
+
"description": "If set, logs the next N polls at INFO level for easier debugging"
|
|
77
91
|
}
|
|
78
92
|
}
|
|
79
93
|
}
|
package/index.js
CHANGED
|
@@ -83,6 +83,7 @@ class EnvoySolarPlatform {
|
|
|
83
83
|
const tick = async () => {
|
|
84
84
|
try {
|
|
85
85
|
const watts = await this.readProductionWatts();
|
|
86
|
+
this.logWatts(watts);
|
|
86
87
|
this.updateState(watts);
|
|
87
88
|
} catch (err) {
|
|
88
89
|
const msg = err && err.message ? err.message : String(err);
|
|
@@ -124,6 +125,38 @@ class EnvoySolarPlatform {
|
|
|
124
125
|
return Boolean(this.config.allowInsecureTLS);
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
isDebugLoggingEnabled() {
|
|
129
|
+
return Boolean(this.config.debugLogging);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
getDebugBurstCount() {
|
|
133
|
+
const n = Number(this.config.debugBurstCount ?? 0);
|
|
134
|
+
if (!Number.isFinite(n) || n < 0) return 0;
|
|
135
|
+
return Math.floor(n);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
consumeDebugBurst() {
|
|
139
|
+
const n = this.getDebugBurstCount();
|
|
140
|
+
if (n <= 0) return 0;
|
|
141
|
+
this.config.debugBurstCount = n - 1;
|
|
142
|
+
return n;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
logWatts(productionWatts) {
|
|
146
|
+
const burst = this.getDebugBurstCount();
|
|
147
|
+
const debugEnabled = this.isDebugLoggingEnabled();
|
|
148
|
+
|
|
149
|
+
if (burst > 0) {
|
|
150
|
+
const before = this.consumeDebugBurst();
|
|
151
|
+
this.log.info(`Envoy production: ${productionWatts} W (debug burst remaining: ${before - 1})`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (debugEnabled) {
|
|
156
|
+
this.log.debug(`Envoy production: ${productionWatts} W`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
127
160
|
markFault() {
|
|
128
161
|
if (!this.accessory) return;
|
|
129
162
|
const service = this.accessory.getService(this.Service.ContactSensor);
|
package/package.json
CHANGED