Closed ei23com closed 4 years ago
And maybe a timestamp in the output like this:
try { msg.payload = { "DateTime": Number(forecastDate.getTime()), "station": weatherForecast[node.mosmixStation].description, "tempc": getForecastedTemperature(node.mosmixStation, forecastDate), "humidity": getForecastedHumidity(node.mosmixStation, forecastDate), "windspeed": Math.round(getInterpolatedValue(node.mosmixStation, "FF", forecastDate) * 10) / 10, "winddirection": Math.round(getInterpolatedValue(node.mosmixStation, "DD", forecastDate) * 10) / 10, "precipitation%": Math.round(getInterpolatedValue(node.mosmixStation, "wwP", forecastDate) * 10) / 10, "precipitationNext24h": Math.round(sumFutureValue(node.mosmixStation, "RR1c", 24, forecastDate) * 10) / 10 };
I have added similar code in v0.1.8. You can now override the look ahead hours via msg.lookAheadHours. There is also a timestamp of the forecast as part of the answer now. I used forecast_dt to stay more consistent with the open weather node naming.
Could you please add something like this to dwdweather.js
[...]
node.on('input', function(msg) { updateWeatherForecastIfOutdated(node) .then(() => { if (weatherForecast[node.mosmixStation]) { var forecastDate = new Date(); forecastDate.setTime(forecastDate.getTime() + node.lookAhead); try{ var mylookAheadHours = Number(msg.payload.lookAheadHours) * 3600000; // Set lookAheadHours with Input forecastDate.setTime(forecastDate.getTime() + mylookAheadHours); } catch (err) { // no input value set }
[...]This would help al lot.