Skip to content

Commit

Permalink
fixing #52
Browse files Browse the repository at this point in the history
  • Loading branch information
baerengraben authored and baerengraben committed Jan 4, 2022
1 parent 5bb91fc commit 45f1163
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,11 +758,32 @@ function setCurrentHour(self){
function updateVariables() {
var promise = new Promise((resolve, reject) => {
self.log.debug('Defining local current_hour variables...');
let path = self.namespace + ".forecast.60minutes.day0"

//get systemtime hour
var date = new Date();
var hour = (date.getHours()<10?'0':'') + date.getHours();

//Fix for https://github.com/baerengraben/ioBroker.swiss-weather-api/issues/52
var path = self.namespace + ".forecast.60minutes.day0";
var forecastDate = new Date();
if (date.getHours()===0){
//check if forecast values already has nextday values in day0/0000
self.getState(self.namespace + ".forecast.60minutes.day0.0000.local_date_time", function (err, state) {
if ((typeof state !== "undefined") && (state !== null)) {
forecastDate = new Date(state.val);
} else {
self.log.error("Cannot read local_date_time" + ':' + 'This should not happen. Please go to github and create an issue.');
}
});

if (date.getDay() === forecastDate.getDay()){
self.log.log("forecast is containing aktual values vor 00:00. So using day0 values");
} else {
self.log.log("forecast is containing yesterdays values vor 00:00. So using day1 values.");
path = self.namespace + ".forecast.60minutes.day1"
}
}

let currentHourVariables = {};
Object.assign(currentHourVariables, {local_background_color: "dummycolor"});
Object.assign(currentHourVariables, {local_temperature : 0});
Expand Down

0 comments on commit 45f1163

Please sign in to comment.