Zren / plasma-applet-eventcalendar

https://store.kde.org/p/998901/
470 stars 93 forks source link

How to modify the weather polling interval? #218

Closed gmm96 closed 3 years ago

gmm96 commented 3 years ago

Option to modify weather polling interval in common app settings is marked as disable, so I cannot modify the polling interval. Parameter cannot either be found in advaced parameters, so I wonder how to do it.

This is important for me, as my system always boots up firstly the widget before the WiFi connection, so I cannot get weather updates unless I manually change the location.

Screenshot_20210213_124215

gmm96 commented 3 years ago

Nothing?

gmm96 commented 3 years ago

Hello?

Zren commented 3 years ago

Hmmm, I assumed I had more work to do after v73 and was going to get back to it, but every time I look at it I don't see a bug?

Doesn't v73 automatically attempt to update weather when the network is connected? Have you installed the latest version of the widget and restarted plasma?

An HTTP Error 0 has never set lastForecastAt = Date.now(), so pressing the agenda refresh should absolutely fetch the weather if the NetworkMonitor didn't work.

I will not lower the update interval as we collectively have a limited amount of OpenWeatherMap API requests. That is why it is disabled.

das22 commented 3 years ago

Likely facing the same issue. Upon restart, no weather information is shown unless I change location. Refreshing agenda does not help. I'm on v73 already.

gmm96 commented 3 years ago

Hmmm, I assumed I had more work to do after v73 and was going to get back to it, but every time I look at it I don't see a bug?

Doesn't v73 automatically attempt to update weather when the network is connected? Have you installed the latest version of the widget and restarted plasma?

An HTTP Error 0 has never set lastForecastAt = Date.now(), so pressing the agenda refresh should absolutely fetch the weather if the NetworkMonitor didn't work.

I will not lower the update interval as we collectively have a limited amount of OpenWeatherMap API requests. That is why it is disabled.

Like @das22 said, no weather information is shown after boots up computer unless I manually change location. Also tried to refresh the agenda and it doesn't solved the weather issue. I'm in v73.

Here's a screenshot showing the bug. As you can see, no weather info is shown while agenda events are successfuly loaded. Pressing agenda does not fetch the weather info.

Screenshot_20210312_162203

Operating System: Manjaro Linux KDE Plasma Version: 5.21.1 KDE Frameworks Version: 5.79.0 Qt Version: 5.15.2 Kernel Version: 5.10.18-1-MANJARO OS Type: 64-bit Graphics Platform: X11 Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz Memory: 15.5 GiB of RAM Graphics Processor: GeForce GTX 960M/PCIe/SSE2

Zren commented 3 years ago

Uhhhg. I've been testing WeatherCanada this whole time (since there isn't an API limit to worry about).

I just tested OpenWeatherMap and noticed a different behavior.

OpenWeatherMap

https://user-images.githubusercontent.com/416367/110969379-9f53d780-8326-11eb-9a66-f6e0d7d58c88.mp4

Loading Calendar plugin HolidaysEventsPlugin(0x55e04ac87140)
3
Trying to take space not available BasicAppletContainer_QMLTYPE_150(0x55e04aac8d40, parent=0x55e04a66c260, geometry=0,0 816x512)
trying to show an empty dialog
qml: OpenWeatherMap.fetchDailyWeatherForecast
qml: OpenWeatherMap.fetchHourlyWeatherForecast
qml: HTTP 0 Headers: 

qml: OpenWeatherMap.fetchDailyWeatherForecast.err HTTP Error 0:  0 
qml: [eventcalendar] updateDailyWeather.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: OpenWeatherMap.fetchDailyWeatherForecast.err XMLHttpRequest.onerror(undefined) undefined undefined
qml: [eventcalendar] updateDailyWeather.err XMLHttpRequest.onerror(undefined) undefined undefined
qml: HTTP 0 Headers: 

qml: updateHourlyWeather.err HTTP Error 0:  0 
qml: [eventcalendar] updateHourlyWeather.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: updateHourlyWeather.err XMLHttpRequest.onerror(undefined) undefined undefined
qml: [eventcalendar] updateHourlyWeather.err XMLHttpRequest.onerror(undefined) undefined undefined
trying to show an empty dialog

WeatherCanada

https://user-images.githubusercontent.com/416367/110969465-babee280-8326-11eb-84af-ab6c935d9f18.mp4

Loading Calendar plugin HolidaysEventsPlugin(0x556d4c8af1e0)
3
Trying to take space not available BasicAppletContainer_QMLTYPE_140(0x556d4c50c330, parent=0x556d4c5a3660, geometry=0,0 816x512)
trying to show an empty dialog
qml: HTTP 0 Headers: 

qml: WeatherCanada.fetchDailyWeatherForecast.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: WeatherCanada.fetchDailyWeatherForecast.err XMLHttpRequest.onerror(undefined) undefined undefined
qml: HTTP 0 Headers: 

qml: WeatherCanada.fetchHourlyWeatherForecast.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: WeatherCanada.fetchHourlyWeatherForecast.err XMLHttpRequest.onerror(undefined) undefined undefined
trying to show an empty dialog
qml: HTTP 0 Headers: 

qml: WeatherCanada.fetchDailyWeatherForecast.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: WeatherCanada.fetchDailyWeatherForecast.err XMLHttpRequest.onerror(undefined) undefined undefined
qml: HTTP 0 Headers: 

qml: WeatherCanada.fetchHourlyWeatherForecast.err HTTP Error 0:  0 
qml: XMLHttpRequest.onerror undefined
qml: WeatherCanada.fetchHourlyWeatherForecast.err XMLHttpRequest.onerror(undefined) undefined undefined
Zren commented 3 years ago

After fixing the WeatherCanada code and adding a bunch of checks, I finally found the bug. Apparently in my Requests.js library I was not passing the xhr to the callback when there's a network error and xhr.onerror() is called. Since xhr wasn't passed to the callback, the code higher up couldn't check if the error was xhr.status == 0 to treat it as a "not connected" error. Since it wasn't, lastForcastErr = Date.now() was set, forcing the user to wait until the next update interval.

Bug should be fixed on git master. I'll publish a release once I fix the plasma-nm issue.