iobroker.sprinklecontrol 1.0.5 → 1.0.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/README.md +7 -31
- package/admin/i18n/de/translations.json +9 -1
- package/admin/i18n/en/translations.json +9 -1
- package/admin/i18n/es/translations.json +8 -0
- package/admin/i18n/fr/translations.json +8 -0
- package/admin/i18n/it/translations.json +8 -0
- package/admin/i18n/nl/translations.json +8 -0
- package/admin/i18n/pl/translations.json +8 -0
- package/admin/i18n/pt/translations.json +8 -0
- package/admin/i18n/ru/translations.json +8 -0
- package/admin/i18n/uk/translations.json +8 -0
- package/admin/i18n/zh-cn/translations.json +8 -0
- package/admin/index_m.html +34 -3
- package/admin/index_m.js +12 -2
- package/admin/words.js +11 -3
- package/io-package.json +32 -29
- package/lib/evaporation.js +5 -5
- package/lib/tools.js +9 -2
- package/lib/valveControl.js +341 -103
- package/main.js +99 -52
- package/package.json +6 -6
package/main.js
CHANGED
|
@@ -84,7 +84,7 @@ function startAdapter(options) {
|
|
|
84
84
|
// is called if a subscribed state changes
|
|
85
85
|
stateChange: async (id, state) => {
|
|
86
86
|
try {
|
|
87
|
-
adapter.log.debug(`stateChange: ${id} (${state ? state.val : 'null'}) ack: ${state ? state.ack : 'null'}`);
|
|
87
|
+
// adapter.log.debug(`stateChange: ${id} (${state ? state.val : 'null'}) ack: ${state ? state.ack : 'null'}`);
|
|
88
88
|
// The state was changed → Der Zustand wurde geändert
|
|
89
89
|
if(state){
|
|
90
90
|
// Change in outside temperature → Änderung der Außentemperatur
|
|
@@ -115,11 +115,38 @@ function startAdapter(options) {
|
|
|
115
115
|
// Windgeschwindigkeit
|
|
116
116
|
if (id === adapter.config.sensorWindSpeed) {
|
|
117
117
|
if (!Number.isNaN(Number.parseFloat(state.val))) {
|
|
118
|
-
|
|
118
|
+
if (adapter.config.unitOfWindSpeed === 'm/s') {
|
|
119
|
+
evaporation.setCurWindSpeed(parseFloat(state.val) * 3.6, state.lc);
|
|
120
|
+
} else if (adapter.config.unitOfWindSpeed === 'km/h') { // HomeMatic: km/h
|
|
121
|
+
evaporation.setCurWindSpeed(parseFloat(state.val), state.lc);
|
|
122
|
+
} else {
|
|
123
|
+
adapter.log.warn(`sensorWindSpeed => No unit selected; therefore, ${state.val} km/h is used. Please check your configuration!`);
|
|
124
|
+
}
|
|
119
125
|
} else {
|
|
120
126
|
adapter.log.warn(`sensorWindSpeed => Wrong value: ${state.val}, Type: ${typeof state.val}`);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
129
|
+
// Drucksensor
|
|
130
|
+
if (id === adapter.config.sensorPressure) {
|
|
131
|
+
adapter.log.debug(`SensorPressure: ${ state?.val }, Type: ${ typeof state.val }`);
|
|
132
|
+
let myPressure;
|
|
133
|
+
if(typeof state.val === 'number') {
|
|
134
|
+
myPressure = parseFloat(state.val);
|
|
135
|
+
}else if(typeof state.val === 'string') {
|
|
136
|
+
myPressure = parseFloat(state.val);
|
|
137
|
+
}else if(typeof state.val === 'boolean') {
|
|
138
|
+
(state.val === true) ? myPressure = 100 : myPressure = 0;
|
|
139
|
+
}
|
|
140
|
+
if(typeof myPressure !== "number"
|
|
141
|
+
|| myPressure > 0
|
|
142
|
+
|| myPressure < 10
|
|
143
|
+
) {
|
|
144
|
+
valveControl.setSensorPressure(state.val);
|
|
145
|
+
} else {
|
|
146
|
+
adapter.log.warn(`SensorPressure (0...10 bar || true/false) => Wrong value: ${ state.val }, Type: ${ typeof state.val }`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
123
150
|
// Regencontainer
|
|
124
151
|
// If the amount of rain is over 20 mm, the 'lastRainCounter' is overwritten and no calculation is carried out. =>
|
|
125
152
|
// * Wenn die Regenmenge mehr als 20 mm beträgt, wird der 'lastRainCounter' überschrieben und es wird keine Berechnung durchgeführt.
|
|
@@ -166,8 +193,8 @@ function startAdapter(options) {
|
|
|
166
193
|
}
|
|
167
194
|
}
|
|
168
195
|
// Füllstand der Zisterne bei Statusänderung
|
|
169
|
-
if (adapter
|
|
170
|
-
valveControl.setFillLevelCistern(
|
|
196
|
+
if (adapter.config?.actualValueLevel && (id === adapter.config.actualValueLevel)) {
|
|
197
|
+
valveControl.setFillLevelCistern(state.val);
|
|
171
198
|
//fillLevelCistern = state.val || 0;
|
|
172
199
|
}
|
|
173
200
|
// Rückmeldungen mit ack === False
|
|
@@ -318,7 +345,7 @@ function startAdapter(options) {
|
|
|
318
345
|
});
|
|
319
346
|
}
|
|
320
347
|
}
|
|
321
|
-
// (state.ack === true)
|
|
348
|
+
// (state.ack === true) => Rückmeldung für das Schalten der Ventile, Druckentlastungsventil, Steuerspannung, Pumpen
|
|
322
349
|
}else if (state.ack === true) {
|
|
323
350
|
// Bestätigung für das Schalten der Ventile
|
|
324
351
|
if (myConfig.config) {
|
|
@@ -336,15 +363,15 @@ function startAdapter(options) {
|
|
|
336
363
|
}
|
|
337
364
|
}
|
|
338
365
|
// Druckentlastungsventil
|
|
339
|
-
if (id === pressureReliefValve
|
|
366
|
+
if (id === pressureReliefValve?.control?.idACK && typeof pressureReliefValve.controller.ackTrue === 'function') {
|
|
340
367
|
pressureReliefValve.controller.ackTrue(state);
|
|
341
368
|
}
|
|
342
369
|
// 24V Steuerspannung
|
|
343
|
-
if (id === controlVoltage
|
|
370
|
+
if (id === controlVoltage?.control?.idACK && typeof controlVoltage.controller.ackTrue === 'function') {
|
|
344
371
|
controlVoltage.controller.ackTrue(state);
|
|
345
372
|
}
|
|
346
373
|
// Pumpe (aktuell verwendete Pumpe)
|
|
347
|
-
if (id === currentPumpUse
|
|
374
|
+
if (id === currentPumpUse?.control?.idACK && typeof currentPumpUse.controller.ackTrue === 'function') {
|
|
348
375
|
currentPumpUse.controller.ackTrue(state);
|
|
349
376
|
}
|
|
350
377
|
// The state was deleted
|
|
@@ -392,9 +419,15 @@ function startAdapter(options) {
|
|
|
392
419
|
* daher können wir bei Bedarf andere Einstellungen als das System verwenden
|
|
393
420
|
*/
|
|
394
421
|
async function GetSystemData() {
|
|
395
|
-
if (typeof adapter.config.longitude === 'undefined'
|
|
396
|
-
||
|
|
397
|
-
|
|
422
|
+
if (typeof adapter.config.longitude === 'undefined'
|
|
423
|
+
|| adapter.config.longitude === null
|
|
424
|
+
|| adapter.config.longitude.length === 0
|
|
425
|
+
|| isNaN(adapter.config.longitude)
|
|
426
|
+
|| typeof adapter.config.latitude === 'undefined'
|
|
427
|
+
|| adapter.config.latitude === null
|
|
428
|
+
|| adapter.config.latitude.length === 0
|
|
429
|
+
|| isNaN(adapter.config.latitude)
|
|
430
|
+
) {
|
|
398
431
|
try {
|
|
399
432
|
const obj = await adapter.getForeignObjectAsync('system.config', 'state');
|
|
400
433
|
|
|
@@ -423,44 +456,48 @@ async function GetSystemData() {
|
|
|
423
456
|
* @param returnOn
|
|
424
457
|
*/
|
|
425
458
|
async function curNextFixDay (sprinkleID, returnOn) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (curTime >= startTimeStr) {
|
|
441
|
-
curDay++;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
for ( let i=0; i<7; i++ ) {
|
|
445
|
-
if (curDay > 6) {
|
|
446
|
-
curDay = curDay - 7;
|
|
459
|
+
try {
|
|
460
|
+
const weekDayArray = myConfig.config[sprinkleID].fixDay.startFixDay;
|
|
461
|
+
const objPfad = `sprinkle.${myConfig.config[sprinkleID].objectName}`;
|
|
462
|
+
const weekday = ['Sun','Mon','Tue','Wed','Thur','Fri','Sat'];
|
|
463
|
+
let found = false;
|
|
464
|
+
let curDay = tools.formatTime().day;
|
|
465
|
+
const d = new Date();
|
|
466
|
+
const curTime = `${zweiStellen(d.getHours())}:${zweiStellen(d.getMinutes())}`;
|
|
467
|
+
|
|
468
|
+
function zweiStellen (s) {
|
|
469
|
+
while (s.toString().length < 2) {
|
|
470
|
+
s = `0${s}`;
|
|
471
|
+
}
|
|
472
|
+
return s;
|
|
447
473
|
}
|
|
448
|
-
if (
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
ack: true
|
|
456
|
-
});
|
|
474
|
+
if (curTime >= startTimeStr) {
|
|
475
|
+
curDay++;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
for ( let i=0; i<7; i++ ) {
|
|
479
|
+
if (curDay > 6) {
|
|
480
|
+
curDay = curDay - 7;
|
|
457
481
|
}
|
|
458
|
-
|
|
482
|
+
if (weekDayArray[curDay] === true) {
|
|
483
|
+
found = true;
|
|
484
|
+
if (returnOn) {
|
|
485
|
+
return weekday[curDay];
|
|
486
|
+
} else {
|
|
487
|
+
adapter.setState(`${objPfad}.actualSoilMoisture`, {
|
|
488
|
+
val: curDay,
|
|
489
|
+
ack: true
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
494
|
+
curDay++;
|
|
459
495
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
496
|
+
if (returnOn && found === false) {
|
|
497
|
+
return 'off';
|
|
498
|
+
}
|
|
499
|
+
} catch (error) {
|
|
500
|
+
adapter.log.error(`Error curNextFixDay: ${error}`);
|
|
464
501
|
}
|
|
465
502
|
}
|
|
466
503
|
|
|
@@ -569,7 +606,7 @@ async function checkStates() {
|
|
|
569
606
|
|
|
570
607
|
/* evaporation.dailyHighTemp */
|
|
571
608
|
const _dailyHighTemp = await adapter.getStateAsync('evaporation.dailyHighTemp');
|
|
572
|
-
if (_dailyHighTemp?.val) {
|
|
609
|
+
if (_dailyHighTemp?.val && typeof _dailyHighTemp.val === 'number') {
|
|
573
610
|
evaporation.setCurTemperatureMax(+_dailyHighTemp.val);
|
|
574
611
|
} else {
|
|
575
612
|
evaporation.setCurTemperatureMax(0);
|
|
@@ -1279,7 +1316,7 @@ async function createSprinklers() {
|
|
|
1279
1316
|
*
|
|
1280
1317
|
* @param {string} methodControlSM
|
|
1281
1318
|
* @param {string} objectName
|
|
1282
|
-
* @returns {Promise<{nameMetConSM: string; objMetConSM: {type: string
|
|
1319
|
+
* @returns {Promise<{nameMetConSM: string; objMetConSM: {type: string; common: {role: string; name: string; type: string; min?: number; max?: number; states?: Record<string, unknown>; unit?: string; read: boolean; write: boolean; def?: number | string | boolean}; native: Record<string, unknown>}}>}
|
|
1283
1320
|
*/
|
|
1284
1321
|
const fillMetConSM = async (methodControlSM, objectName) => {
|
|
1285
1322
|
//adapter.log.debug(JSON.stringify(res));
|
|
@@ -1313,7 +1350,7 @@ async function createSprinklers() {
|
|
|
1313
1350
|
write: false,
|
|
1314
1351
|
def: 50
|
|
1315
1352
|
},
|
|
1316
|
-
native: {}
|
|
1353
|
+
native: {}
|
|
1317
1354
|
}
|
|
1318
1355
|
};
|
|
1319
1356
|
}
|
|
@@ -2123,7 +2160,7 @@ async function delOldSprinklers(result) {
|
|
|
2123
2160
|
*/
|
|
2124
2161
|
const delWhenExistObjectAsync = async (id, type) => {
|
|
2125
2162
|
const _find = await adapter.findForeignObjectAsync(`${id}`, `${type}`);
|
|
2126
|
-
if (_find
|
|
2163
|
+
if (_find?.id === `${id}`) {
|
|
2127
2164
|
await adapter.delObjectAsync(`${id}`).catch((e) => adapter.log.warn(e)); // "sprinklecontrol.0.sprinkle.???.postponeByOneDay"
|
|
2128
2165
|
}
|
|
2129
2166
|
};
|
|
@@ -2174,8 +2211,8 @@ async function main() {
|
|
|
2174
2211
|
* The adapters' config (in the instance object everything under the attribute "native") is accessible via adapter.config:
|
|
2175
2212
|
* => Auf die Adapterkonfiguration (im Instanz objekt alles unter dem Attribut "native") kann zugegriffen werden über adapter.config:
|
|
2176
2213
|
*
|
|
2177
|
-
* @param {
|
|
2178
|
-
* @param {
|
|
2214
|
+
* @param {objett} err
|
|
2215
|
+
* @param {objekt} obj
|
|
2179
2216
|
*/
|
|
2180
2217
|
// @ts-ignore
|
|
2181
2218
|
// @ts-ignore
|
|
@@ -2204,6 +2241,7 @@ async function main() {
|
|
|
2204
2241
|
//adapter.subscribeStates('info.Elevation');
|
|
2205
2242
|
//adapter.subscribeStates('info.Azimut');
|
|
2206
2243
|
|
|
2244
|
+
// Trigger für die Wettervorhersage abonnieren, wenn in der Config angegeben
|
|
2207
2245
|
if (adapter.config.weatherForecastService === 'ownDataPoint') {
|
|
2208
2246
|
weatherForecastTodayPfadStr = adapter.config.pathRainForecast;
|
|
2209
2247
|
adapter.subscribeForeignStates(weatherForecastTodayPfadStr);
|
|
@@ -2221,9 +2259,12 @@ async function main() {
|
|
|
2221
2259
|
adapter.subscribeForeignStates(`${ adapter.config.publicHolInstance }.morgen.*`);
|
|
2222
2260
|
}
|
|
2223
2261
|
|
|
2262
|
+
// Trigger für die Bewässerung abonnieren, wenn in der Config angegeben
|
|
2224
2263
|
if (adapter.config.triggerControlVoltage !== '') {
|
|
2225
2264
|
await adapter.subscribeForeignStatesAsync(adapter.config.triggerControlVoltage);
|
|
2226
2265
|
}
|
|
2266
|
+
|
|
2267
|
+
// Trigger für die Pumpe abonnieren, wenn in der Config angegeben
|
|
2227
2268
|
switch(adapter.config.pumpSelection) {
|
|
2228
2269
|
case 'noPump':
|
|
2229
2270
|
break;
|
|
@@ -2239,6 +2280,7 @@ async function main() {
|
|
|
2239
2280
|
break;
|
|
2240
2281
|
}
|
|
2241
2282
|
|
|
2283
|
+
// Level-Sensor abonnieren, wenn in der Config angegeben
|
|
2242
2284
|
if (adapter.config.actualValueLevel !== '') {
|
|
2243
2285
|
await adapter.subscribeForeignStatesAsync(adapter.config.actualValueLevel);
|
|
2244
2286
|
} else if ((adapter.config.pumpSelection === 'pumpAndCistern') || (adapter.config.pumpSelection === 'cistern')) {
|
|
@@ -2248,6 +2290,11 @@ async function main() {
|
|
|
2248
2290
|
}).catch((e) => adapter.log.warn(`info.cisternState ${e}`));
|
|
2249
2291
|
}
|
|
2250
2292
|
|
|
2293
|
+
// Bodenfeuchte-Sensoren abonnieren, wenn in der Config angegeben
|
|
2294
|
+
if (adapter.config.sensorPressure.length > 10) {
|
|
2295
|
+
await adapter.subscribeForeignStatesAsync(adapter.config.sensorPressure);
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2251
2298
|
await checkActualStates().catch((e) => adapter.log.warn(`checkActualStates: ${e}`));
|
|
2252
2299
|
// @ts-ignore
|
|
2253
2300
|
timer = setTimeout(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.sprinklecontrol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Control of several sprinklers depending on weather conditions and pump performance.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Dirk Peter",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"suncalc": "^1.9.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@alcalzone/release-script": "^5.
|
|
38
|
-
"@alcalzone/release-script-plugin-iobroker": "^5.
|
|
39
|
-
"@alcalzone/release-script-plugin-license": "^5.
|
|
40
|
-
"@alcalzone/release-script-plugin-manual-review": "^5.
|
|
37
|
+
"@alcalzone/release-script": "^5.2.0",
|
|
38
|
+
"@alcalzone/release-script-plugin-iobroker": "^5.2.0",
|
|
39
|
+
"@alcalzone/release-script-plugin-license": "^5.2.0",
|
|
40
|
+
"@alcalzone/release-script-plugin-manual-review": "^5.2.0",
|
|
41
41
|
"@iobroker/adapter-dev": "^1.5.0",
|
|
42
|
-
"@iobroker/eslint-config": "^2.
|
|
42
|
+
"@iobroker/eslint-config": "^2.3.4",
|
|
43
43
|
"@iobroker/testing": "^5.2.2"
|
|
44
44
|
},
|
|
45
45
|
"main": "main.js",
|