Use today's local PWS data if yesterday's data is not available
Fixes #73
This commit is contained in:
@@ -48,9 +48,10 @@ export default class LocalWeatherProvider extends WeatherProvider {
|
|||||||
|
|
||||||
public async getWateringData( coordinates: GeoCoordinates ): Promise< ZimmermanWateringData > {
|
public async getWateringData( coordinates: GeoCoordinates ): Promise< ZimmermanWateringData > {
|
||||||
const result: ZimmermanWateringData = {
|
const result: ZimmermanWateringData = {
|
||||||
...yesterday as ZimmermanWateringData,
|
// Use today's weather if we don't have information for yesterday yet (i.e. on startup)
|
||||||
// Use today's weather if we dont have information for yesterday yet (i.e. on startup)
|
|
||||||
...today,
|
...today,
|
||||||
|
// Use yesterday's weather updated every midnight, if available after startup
|
||||||
|
...yesterday as ZimmermanWateringData,
|
||||||
// PWS report "buckets" so consider it still raining if last bucket was less than an hour ago
|
// PWS report "buckets" so consider it still raining if last bucket was less than an hour ago
|
||||||
raining: last_bucket !== undefined ? ( ( Date.now() - +last_bucket ) / 1000 / 60 / 60 < 1 ) : undefined,
|
raining: last_bucket !== undefined ? ( ( Date.now() - +last_bucket ) / 1000 / 60 / 60 < 1 ) : undefined,
|
||||||
weatherProvider: "local"
|
weatherProvider: "local"
|
||||||
|
|||||||
Reference in New Issue
Block a user