Skip to content

Commit

Permalink
Merge pull request #78 from phifogg/dev
Browse files Browse the repository at this point in the history
0.7.2 merge - security vulnerability in dependencies
  • Loading branch information
phifogg authored May 10, 2021
2 parents c1bee80 + 640f43b commit 0bd1216
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esversion": 8
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ The schheduler will start and connect to the weather station after the first int

Latest version

#### 0.7.1 Fixes mapping for soilbat values
#### 0.7.2 Dependency updates for security vulnerabilities

#### 0.7.0 #64 added soilmoisture devices
#### 0.7.1 Fix Soilbatt mapping

#### 0.7.0 Support for Soil Moisture devices like attached to DP1500

#### 0.6.6 Adressed github issue #53 - warning on non existing object

Expand Down
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* ioBroker gulpfile
* Date: 2019-01-28
*/
/* jshint node: true */

'use strict';

const gulp = require('gulp');
Expand Down
6 changes: 5 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"common": {
"name": "sainlogic",
"version": "0.7.1",
"version": "0.7.2",
"news": {
"0.7.2": {
"en": "Security fixes in dependencies",
"de": "Update von Abhängigkeiten wegen möglichen Sicherheitsmeldungen"
},
"0.7.1": {
"en": "Fix Soilbatt mapping",
"de": "Korrektur für Batterielevel der Bodenfeuchtigkeitssensoren"
Expand Down
4 changes: 2 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const DATAFIELDS = [
name: 'Last data received from Listener (raw)'
}],
type: 'string',
wunderground: null,
ecowitt: null,
wunderground: 'last_listener_update',
ecowitt: 'last_listener_update',
scheduler: null,
listener_conversion: null,
scheduler_conversion: null
Expand Down
4 changes: 3 additions & 1 deletion lib/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class Listener {

if (my_path == this.path) {
this.adapter.log.debug('Listener received WU update: ' + JSON.stringify(json_response));
this.adapter.setStateAsync('info.last_listener_update', { val: JSON.stringify(json_response), ack: true });
// add full string property
json_response.last_listener_update = json_response;
// last_listener_update this.adapter.setStateAsync('info.last_listener_update', { val: JSON.stringify(json_response), ack: true });

response.writeHead(200, { 'Content-Type': 'text/html' });
response.end();
Expand Down
4 changes: 2 additions & 2 deletions lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ async function translateYandex(text, targetLang, apiKey) {
try {
const url = `https://translate.yandex.net/api/v1.5/tr.json/translate?key=${apiKey}&text=${encodeURIComponent(text)}&lang=en-${targetLang}`;
const response = await axios({url, timeout: 15000});
if (response.data && response.data['text']) {
return response.data['text'][0];
if (response.data && response.data.text) {
return response.data.text[0];
}
throw new Error('Invalid response for translate request');
} catch (e) {
Expand Down
18 changes: 14 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* jshint node: true */
// @ts-nocheck
'use strict';

/*
Expand All @@ -7,7 +9,7 @@
// The adapter-core module gives you access to the core ioBroker functions
// you need to create an adapter
const utils = require('@iobroker/adapter-core');
const util = require('util');
//const util = require('util');
const Parser = require('expr-eval').Parser;

// Load your modules here, e.g.:
Expand All @@ -22,6 +24,7 @@ class Sainlogic extends utils.Adapter {
/**
* @param {Partial<ioBroker.AdapterOptions>} [options={}]
*/
// eslint-disable-next-line no-unused-vars
constructor(options) {
super({
name: 'sainlogic',
Expand Down Expand Up @@ -139,19 +142,25 @@ class Sainlogic extends utils.Adapter {


verify_datapoint(obj_id, that, attrdef, attrname, value) {

// check target type and type-cast if needed
if (attrdef.type == 'number') {
value = parseFloat(value);
}

this.getObject(obj_id, function (err, obj) {
if (err || obj == null) {

let existing = 0;

if ((that.config.scheduler_active == true) && (attrdef.scheduler != null)) { existing++ }
if ((that.config.scheduler_active == true) && (attrdef.scheduler != null)) { existing++; }
if (that.config.listener_active == true) {
switch (that.config.listener_protocol) {
case PROT_WU:
if(attrdef.wunderground != null) { existing++ }
if(attrdef.wunderground != null) { existing++; }
break;
case PROT_EW:
if(attrdef.ecowitt != null) { existing++ }
if(attrdef.ecowitt != null) { existing++; }
break;
}
}
Expand All @@ -176,6 +185,7 @@ class Sainlogic extends utils.Adapter {
},
},
native: {},
// eslint-disable-next-line no-unused-vars
}, function (err, obj) {
// now update the value
that.setStateAsync(obj_id, value);
Expand Down
Loading

0 comments on commit 0bd1216

Please # to comment.