Skip to content

Commit

Permalink
0.0.15 - min/max update only when changed
Browse files Browse the repository at this point in the history
  • Loading branch information
woessmich committed Jan 21, 2021
1 parent e4cbc4a commit 53a1597
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Further, the adapter provides a selection of useful minimum and maximum values o
The protocol sends a lightning distance of 0 when no lightning was detected. Values of 0 are modified to 999 to avoid the impression that lightning strikes are directly overhead.

## Changelog
### 0.0.15
(womi) only update min/max values if value has changed
### 0.0.14
(womi) Corrected wind chill calculation in feels like temperature calculation
### 0.0.13
Expand Down
10 changes: 7 additions & 3 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"common": {
"name": "weatherflow_udp",
"version": "0.0.14",
"version": "0.0.15",
"news": {
"0.0.15": {
"en": "only update min/max values if value has changed",
"de": "min/max nur noch aktualisiert bei Änderungen"
},
"0.0.14": {
"en": "corrected calculation of windchill in feels like temperature",
"de": "Wind chill Temperatur korrigiert"
"en": "corrected calculation of windchill in feels like temperature; only update min/max values if value has changed",
"de": "Wind chill Temperatur korrigiert; min/max nur noch aktualisiert bei Änderungen"
},
"0.0.13": {
"en": "Corrected precipitation duration; changed boolean raining behaviour",
Expand Down
24 changes: 12 additions & 12 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,25 +908,25 @@ class WeatherflowUdp extends utils.Adapter {
if (obj !== null) {
if (now.getDay() === oldNow.getDay()) { // same day
let newMinmaxValue;
if (obj.val !== stateValue) {
switch (calcType) {
case MIN:
newMinmaxValue = Math.min(obj.val, stateValue); // calculate new min value
break;
switch (calcType) {
case MIN:
newMinmaxValue = Math.min(obj.val, stateValue); // calculate new min value
break;

case MAX:
newMinmaxValue = Math.max(obj.val, stateValue); // calculate new min value
break;
case MAX:
newMinmaxValue = Math.max(obj.val, stateValue); // calculate new min value
break;

default:
}
default:
}
if (obj.val !== newMinmaxValue) { //only update state if value is different
this.myCreateState(minmaxStateNameToday, minmaxStateParametersToday, newMinmaxValue); // create and/or write node
}
} else { // new day, always update
this.myCreateState(minmaxStateNameToday, minmaxStateParametersToday, stateValue); // On a new day, first value is the minimum of 'today'
this.myCreateState(minmaxStateNameYesterday, minmaxStateParametersYesterday, obj.val); // Values for yesterday are last min value from today
}
} else { // min or max state does not yet exist
} else { // min or max state does not yet exist, create
this.myCreateState(minmaxStateNameToday, minmaxStateParametersToday, stateValue); // if not existing, create
}
}
Expand Down Expand Up @@ -1053,7 +1053,7 @@ function feelsLike(temperature, windspeed, humidity) {
} else {
feelsLikeTemperature = temperature;
}
feelsLikeTemperature = Math.round(feelsLikeTemperature * 10) / 10; // round to 1 decimal only
feelsLikeTemperature = Math.round(feelsLikeTemperature * 10) / 10; // round to 1 decimal only

return feelsLikeTemperature;
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53a1597

Please sign in to comment.