iobroker.sprinklecontrol 1.0.6 → 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/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
- evaporation.setCurWindSpeed(parseFloat(state.val), state.lc);
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.
@@ -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) {
@@ -1289,7 +1316,7 @@ async function createSprinklers() {
1289
1316
  *
1290
1317
  * @param {string} methodControlSM
1291
1318
  * @param {string} objectName
1292
- * @returns {Promise<{nameMetConSM: string; objMetConSM: {type: string, common: {role: string, name: string, type: string, min?: number, max?: number, states?: {}, unit?: string, read: boolean, write: boolean, def?: number | string | boolean}, native: {}}}>}
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>}}>}
1293
1320
  */
1294
1321
  const fillMetConSM = async (methodControlSM, objectName) => {
1295
1322
  //adapter.log.debug(JSON.stringify(res));
@@ -1323,7 +1350,7 @@ async function createSprinklers() {
1323
1350
  write: false,
1324
1351
  def: 50
1325
1352
  },
1326
- native: {},
1353
+ native: {}
1327
1354
  }
1328
1355
  };
1329
1356
  }
@@ -2184,8 +2211,8 @@ async function main() {
2184
2211
  * The adapters' config (in the instance object everything under the attribute "native") is accessible via adapter.config:
2185
2212
  * => Auf die Adapterkonfiguration (im Instanz objekt alles unter dem Attribut "native") kann zugegriffen werden über adapter.config:
2186
2213
  *
2187
- * @param {any} err
2188
- * @param {any} obj
2214
+ * @param {objett} err
2215
+ * @param {objekt} obj
2189
2216
  */
2190
2217
  // @ts-ignore
2191
2218
  // @ts-ignore
@@ -2214,6 +2241,7 @@ async function main() {
2214
2241
  //adapter.subscribeStates('info.Elevation');
2215
2242
  //adapter.subscribeStates('info.Azimut');
2216
2243
 
2244
+ // Trigger für die Wettervorhersage abonnieren, wenn in der Config angegeben
2217
2245
  if (adapter.config.weatherForecastService === 'ownDataPoint') {
2218
2246
  weatherForecastTodayPfadStr = adapter.config.pathRainForecast;
2219
2247
  adapter.subscribeForeignStates(weatherForecastTodayPfadStr);
@@ -2231,9 +2259,12 @@ async function main() {
2231
2259
  adapter.subscribeForeignStates(`${ adapter.config.publicHolInstance }.morgen.*`);
2232
2260
  }
2233
2261
 
2262
+ // Trigger für die Bewässerung abonnieren, wenn in der Config angegeben
2234
2263
  if (adapter.config.triggerControlVoltage !== '') {
2235
2264
  await adapter.subscribeForeignStatesAsync(adapter.config.triggerControlVoltage);
2236
2265
  }
2266
+
2267
+ // Trigger für die Pumpe abonnieren, wenn in der Config angegeben
2237
2268
  switch(adapter.config.pumpSelection) {
2238
2269
  case 'noPump':
2239
2270
  break;
@@ -2249,6 +2280,7 @@ async function main() {
2249
2280
  break;
2250
2281
  }
2251
2282
 
2283
+ // Level-Sensor abonnieren, wenn in der Config angegeben
2252
2284
  if (adapter.config.actualValueLevel !== '') {
2253
2285
  await adapter.subscribeForeignStatesAsync(adapter.config.actualValueLevel);
2254
2286
  } else if ((adapter.config.pumpSelection === 'pumpAndCistern') || (adapter.config.pumpSelection === 'cistern')) {
@@ -2258,6 +2290,11 @@ async function main() {
2258
2290
  }).catch((e) => adapter.log.warn(`info.cisternState ${e}`));
2259
2291
  }
2260
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
+
2261
2298
  await checkActualStates().catch((e) => adapter.log.warn(`checkActualStates: ${e}`));
2262
2299
  // @ts-ignore
2263
2300
  timer = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sprinklecontrol",
3
- "version": "1.0.6",
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",