iobroker.pvnode 0.2.3 → 0.2.4
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 +8 -1
- package/io-package.json +14 -1
- package/lib/svg.js +2 -2
- package/main.js +55 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,14 @@ Many thanks to the pvnode team for providing their service and the public API th
|
|
|
78
78
|
### **WORK IN PROGRESS**
|
|
79
79
|
-->
|
|
80
80
|
|
|
81
|
-
### 0.2.
|
|
81
|
+
### 0.2.4 (2026-11-22)
|
|
82
|
+
|
|
83
|
+
- States with custom settings (e.g. history, InfluxDB, SQL) are no longer deleted when they are not needed anymore; a warning is logged instead
|
|
84
|
+
- Random delay of up to 90 seconds per installation before each forecast request, so not all installations ask pvnode at the same second
|
|
85
|
+
- Chart texts fall back to English if the system language cannot be read
|
|
86
|
+
- Small code cleanups (English compass abbreviations, handled promise for `info.nextPoll`)
|
|
87
|
+
|
|
88
|
+
### 0.2.3 (2026-11-22)
|
|
82
89
|
|
|
83
90
|
- All object names (states and channels) translated into the 11 ioBroker languages (repository checker E6001)
|
|
84
91
|
- `info.requestsLimit` and `info.requestsRemaining` are now numbers; `-1` means unlimited ("unmetered") plan (E3005/E1009)
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "pvnode",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.2.4": {
|
|
7
|
+
"en": "States with custom settings (history etc.) are no longer deleted, random delay before forecast requests, small code cleanups",
|
|
8
|
+
"de": "Datenpunkte mit Custom-Einstellungen (History usw.) werden nicht mehr gelöscht, zufällige Verzögerung vor Prognose-Abfragen, kleine Code-Aufräumarbeiten",
|
|
9
|
+
"ru": "Состояния с пользовательскими настройками (история и т. п.) больше не удаляются, случайная задержка перед запросами прогноза, небольшая чистка кода",
|
|
10
|
+
"pt": "Estados com definições personalizadas (histórico, etc.) já não são eliminados, atraso aleatório antes dos pedidos de previsão, pequenas limpezas de código",
|
|
11
|
+
"nl": "Statussen met aangepaste instellingen (history enz.) worden niet meer verwijderd, willekeurige vertraging vóór voorspellingsaanvragen, kleine code-opschoning",
|
|
12
|
+
"fr": "Les états avec des paramètres personnalisés (historique, etc.) ne sont plus supprimés, délai aléatoire avant les requêtes de prévision, petits nettoyages du code",
|
|
13
|
+
"it": "Gli stati con impostazioni personalizzate (cronologia ecc.) non vengono più eliminati, ritardo casuale prima delle richieste di previsione, piccole pulizie del codice",
|
|
14
|
+
"es": "Los estados con ajustes personalizados (historial, etc.) ya no se eliminan, retraso aleatorio antes de las solicitudes de previsión, pequeñas limpiezas de código",
|
|
15
|
+
"pl": "Stany z ustawieniami niestandardowymi (historia itp.) nie są już usuwane, losowe opóźnienie przed zapytaniami o prognozę, drobne porządki w kodzie",
|
|
16
|
+
"uk": "Стани з користувацькими налаштуваннями (історія тощо) більше не видаляються, випадкова затримка перед запитами прогнозу, невелике прибирання коду",
|
|
17
|
+
"zh-cn": "带有自定义设置(历史记录等)的状态不再被删除,预测请求前加入随机延迟,少量代码清理"
|
|
18
|
+
},
|
|
6
19
|
"0.2.3": {
|
|
7
20
|
"en": "All object names translated into 11 languages, request limit as number (-1 = unlimited), units and roles refined; existing objects are updated",
|
|
8
21
|
"de": "Alle Objektnamen in 11 Sprachen übersetzt, Anfragelimit als Zahl (-1 = unbegrenzt), Einheiten und Rollen verbessert; bestehende Objekte werden aktualisiert",
|
package/lib/svg.js
CHANGED
|
@@ -74,7 +74,7 @@ function pathFrom(points) {
|
|
|
74
74
|
* @param {string[]} [opt.stringNames] names per string index
|
|
75
75
|
*/
|
|
76
76
|
function dayChart(p, now, opt = {}) {
|
|
77
|
-
const T = TEXT[opt.lang] || TEXT.
|
|
77
|
+
const T = TEXT[opt.lang] || TEXT.en;
|
|
78
78
|
const W = 1000;
|
|
79
79
|
const H = 360;
|
|
80
80
|
const m = { l: 56, r: 16, t: 34, b: 34 };
|
|
@@ -189,7 +189,7 @@ function dayChart(p, now, opt = {}) {
|
|
|
189
189
|
* @param {string} [opt.lang] 'de' | 'en'
|
|
190
190
|
*/
|
|
191
191
|
function daysChart(p, now, opt = {}) {
|
|
192
|
-
const T = TEXT[opt.lang] || TEXT.
|
|
192
|
+
const T = TEXT[opt.lang] || TEXT.en;
|
|
193
193
|
const today = localDate(now, p.tz);
|
|
194
194
|
const days = p.daily.filter(d => d.date >= today && typeof d.pv_energy_kwh === 'number');
|
|
195
195
|
const W = 600;
|
package/main.js
CHANGED
|
@@ -20,6 +20,8 @@ const { localDate, isoLocal } = require('./lib/time');
|
|
|
20
20
|
const { dayChart, daysChart } = require('./lib/svg');
|
|
21
21
|
|
|
22
22
|
const GRACE_MS = 30 * 1000;
|
|
23
|
+
// random extra delay per instance, so not all installations poll pvnode at the same second
|
|
24
|
+
const JITTER_MAX_MS = 90 * 1000;
|
|
23
25
|
const MIN_DELAY_MS = 60 * 1000;
|
|
24
26
|
const MAX_DELAY_MS = 24 * 3600 * 1000;
|
|
25
27
|
const FALLBACK_DELAY_MS = 3600 * 1000;
|
|
@@ -30,7 +32,7 @@ const MAX_STRINGS = 8;
|
|
|
30
32
|
const OPTIONAL_GROUPS = ['weather', 'irradiance', 'clearsky'];
|
|
31
33
|
|
|
32
34
|
function compass(deg) {
|
|
33
|
-
const names = ['N', '
|
|
35
|
+
const names = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
|
|
34
36
|
if (typeof deg !== 'number') {
|
|
35
37
|
return '?';
|
|
36
38
|
}
|
|
@@ -68,8 +70,10 @@ class Pvnode extends utils.Adapter {
|
|
|
68
70
|
this.polling = false;
|
|
69
71
|
this.stopped = false;
|
|
70
72
|
this.created = new Set();
|
|
71
|
-
this.lang = '
|
|
73
|
+
this.lang = 'en';
|
|
72
74
|
this.stringNames = [];
|
|
75
|
+
this.pollOffsetMs = GRACE_MS + Math.floor(Math.random() * JITTER_MAX_MS);
|
|
76
|
+
this.customWarned = new Set();
|
|
73
77
|
|
|
74
78
|
this.on('ready', this.onReady.bind(this));
|
|
75
79
|
this.on('stateChange', this.onStateChange.bind(this));
|
|
@@ -91,7 +95,7 @@ class Pvnode extends utils.Adapter {
|
|
|
91
95
|
const sys = await this.getForeignObjectAsync('system.config');
|
|
92
96
|
this.lang = sys && sys.common && sys.common.language === 'de' ? 'de' : 'en';
|
|
93
97
|
} catch {
|
|
94
|
-
this.lang = '
|
|
98
|
+
this.lang = 'en';
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
const apiKey = String(this.config.apiKey || '').trim();
|
|
@@ -145,7 +149,7 @@ class Pvnode extends utils.Adapter {
|
|
|
145
149
|
const restored = await this.restoreCache();
|
|
146
150
|
if (restored && restored.nextPollAt && restored.nextPollAt > Date.now()) {
|
|
147
151
|
this.log.info(`Using cached forecast, next poll at ${new Date(restored.nextPollAt).toISOString()}`);
|
|
148
|
-
this.schedulePoll(restored.nextPollAt - Date.now() +
|
|
152
|
+
this.schedulePoll(restored.nextPollAt - Date.now() + this.pollOffsetMs);
|
|
149
153
|
} else {
|
|
150
154
|
await this.poll();
|
|
151
155
|
}
|
|
@@ -217,7 +221,9 @@ class Pvnode extends utils.Adapter {
|
|
|
217
221
|
this.pollTimer = null;
|
|
218
222
|
this.poll().catch(e => this.log.error(`Poll failed: ${e.message}`));
|
|
219
223
|
}, delay);
|
|
220
|
-
this.
|
|
224
|
+
this.setStateAsync('info.nextPoll', new Date(Date.now() + delay).toISOString(), true).catch(e =>
|
|
225
|
+
this.log.debug(`Could not write info.nextPoll: ${e.message}`),
|
|
226
|
+
);
|
|
221
227
|
this.log.debug(`Next poll in ${Math.round(delay / 60000)} min`);
|
|
222
228
|
}
|
|
223
229
|
|
|
@@ -288,7 +294,7 @@ class Pvnode extends utils.Adapter {
|
|
|
288
294
|
await this.setStateAsync('info.lastError', '', true);
|
|
289
295
|
|
|
290
296
|
const next = body.next_poll_at ? Date.parse(body.next_poll_at) : NaN;
|
|
291
|
-
this.schedulePoll(Number.isFinite(next) ? next - Date.now() +
|
|
297
|
+
this.schedulePoll(Number.isFinite(next) ? next - Date.now() + this.pollOffsetMs : FALLBACK_DELAY_MS);
|
|
292
298
|
if (manual) {
|
|
293
299
|
this.log.info('Manual refresh done');
|
|
294
300
|
}
|
|
@@ -333,7 +339,7 @@ class Pvnode extends utils.Adapter {
|
|
|
333
339
|
const until = Number.isFinite(reset) ? reset : Date.now() + MAX_DELAY_MS;
|
|
334
340
|
this.log.warn(`pvnode monthly request limit reached. Pausing until ${new Date(until).toISOString()}`);
|
|
335
341
|
await this.setStateAsync('info.stale', true, true);
|
|
336
|
-
this.schedulePoll(Math.min(until - Date.now() +
|
|
342
|
+
this.schedulePoll(Math.min(until - Date.now() + this.pollOffsetMs, MAX_DELAY_MS));
|
|
337
343
|
return;
|
|
338
344
|
}
|
|
339
345
|
|
|
@@ -528,8 +534,7 @@ class Pvnode extends utils.Adapter {
|
|
|
528
534
|
for (let i = count; i < max; i++) {
|
|
529
535
|
const id = `${root}.${i}`;
|
|
530
536
|
const obj = await this.getObjectAsync(id);
|
|
531
|
-
if (obj) {
|
|
532
|
-
await this.delObjectAsync(id, { recursive: true });
|
|
537
|
+
if (obj && (await this.deleteUnlessCustom(id, true))) {
|
|
533
538
|
for (const k of [...this.created]) {
|
|
534
539
|
if (k === id || k.startsWith(`${id}.`)) {
|
|
535
540
|
this.created.delete(k);
|
|
@@ -539,6 +544,38 @@ class Pvnode extends utils.Adapter {
|
|
|
539
544
|
}
|
|
540
545
|
}
|
|
541
546
|
|
|
547
|
+
/**
|
|
548
|
+
* Delete an own object (optionally with children), but keep it if it or one of its children
|
|
549
|
+
* has custom settings (e.g. history, influxdb, sql), so the user's configuration is not lost.
|
|
550
|
+
*
|
|
551
|
+
* @param {string} id relative id
|
|
552
|
+
* @param {boolean} recursive also delete children
|
|
553
|
+
* @returns {Promise<boolean>} true if deleted
|
|
554
|
+
*/
|
|
555
|
+
async deleteUnlessCustom(id, recursive) {
|
|
556
|
+
const obj = await this.getObjectAsync(id);
|
|
557
|
+
if (!obj) {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
const objs = [obj];
|
|
561
|
+
if (recursive) {
|
|
562
|
+
const children = await this.getForeignObjectsAsync(`${this.namespace}.${id}.*`);
|
|
563
|
+
objs.push(...Object.values(children || {}));
|
|
564
|
+
}
|
|
565
|
+
const withCustom = objs.find(o => o && o.common && o.common.custom && Object.keys(o.common.custom).length);
|
|
566
|
+
if (withCustom) {
|
|
567
|
+
if (!this.customWarned.has(id)) {
|
|
568
|
+
this.customWarned.add(id);
|
|
569
|
+
this.log.warn(
|
|
570
|
+
`${withCustom._id || id} is no longer needed but has custom settings (e.g. history), so it is not deleted. Remove the custom settings or delete it manually.`,
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
await this.delObjectAsync(id, { recursive });
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
|
|
542
579
|
async cleanupOptionalWeather() {
|
|
543
580
|
const wanted = new Set();
|
|
544
581
|
if (this.config.includeWeather) {
|
|
@@ -556,22 +593,13 @@ class Pvnode extends utils.Adapter {
|
|
|
556
593
|
}
|
|
557
594
|
for (const f of WEATHER_FIELDS) {
|
|
558
595
|
if (!wanted.has(f)) {
|
|
559
|
-
|
|
560
|
-
if (obj) {
|
|
561
|
-
await this.delObjectAsync(`weather.${f}`);
|
|
562
|
-
}
|
|
596
|
+
await this.deleteUnlessCustom(`weather.${f}`, false);
|
|
563
597
|
}
|
|
564
598
|
}
|
|
565
599
|
if (!this.config.includeClearsky) {
|
|
566
|
-
|
|
567
|
-
if (await this.getObjectAsync(id)) {
|
|
568
|
-
await this.delObjectAsync(id);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
600
|
+
await this.deleteUnlessCustom('now.power_clearsky', false);
|
|
571
601
|
for (let i = 0; i < MAX_DAYS; i++) {
|
|
572
|
-
|
|
573
|
-
await this.delObjectAsync(`days.${i}.energy_clearsky`);
|
|
574
|
-
}
|
|
602
|
+
await this.deleteUnlessCustom(`days.${i}.energy_clearsky`, false);
|
|
575
603
|
}
|
|
576
604
|
}
|
|
577
605
|
}
|
|
@@ -584,9 +612,9 @@ class Pvnode extends utils.Adapter {
|
|
|
584
612
|
await this.setStateAsync('site.power_kw', Math.round(total * 100) / 100, true);
|
|
585
613
|
const dirDe = {
|
|
586
614
|
N: 'Nord',
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
615
|
+
NE: 'Nordost',
|
|
616
|
+
E: 'Ost',
|
|
617
|
+
SE: 'Südost',
|
|
590
618
|
S: 'Süd',
|
|
591
619
|
SW: 'Südwest',
|
|
592
620
|
W: 'West',
|
|
@@ -594,9 +622,9 @@ class Pvnode extends utils.Adapter {
|
|
|
594
622
|
};
|
|
595
623
|
const dirEn = {
|
|
596
624
|
N: 'North',
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
625
|
+
NE: 'Northeast',
|
|
626
|
+
E: 'East',
|
|
627
|
+
SE: 'Southeast',
|
|
600
628
|
S: 'South',
|
|
601
629
|
SW: 'Southwest',
|
|
602
630
|
W: 'West',
|