SignalK / freeboard-sk

Chartplotter implementation for Signal K servers
Apache License 2.0
35 stars 27 forks source link

"No weather data found." #152

Closed DrStS closed 3 months ago

DrStS commented 4 months ago

I have configured the openweather API v3 and have also checked if it is working. The API calls together with my key are working in the command line. Yet if I am using it through freeboard-sk I always get "No weather data found." Unfortunately, the debug log did not help me either. Is there a trick how to get it enabled? Thanks, best Stefan

panaaj commented 4 months ago

If you turn on debugging for the Freeboard-SK plugin you should see messages that indicate what is happening.

There needs to be a vessel position for else it will not fetch the data.

Any data fetched by the plugin will appear in the data browser on the server under the meteo.freeboard-sk context.

DrStS commented 4 months ago

Thanks a lot for the advice. Is there a way to fake the vessel position?

panaaj commented 4 months ago

You can enter information in "data fiddler" in the server admin UI or (what I use) is SKSim which you can install on the server via the app store.

DrStS commented 4 months ago

Thanks when I do that. I get this in the debug console. Apr 22 10:16:05 2024-04-22T08:16:05.344Z @signalk/freeboard-sk GET /signalk/v2/api/meteo/:id/forecasts Apr 22 10:16:05 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:05 +0000] "GET /signalk/v2/api/meteo/freeboard-sk/forecasts HTTP/1.1" 304 - "http://sickiboat/@signalk/freeboard-sk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:07 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:07 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:09 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:09 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:11 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:11 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:13 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:13 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:15 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:15 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:17 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:17 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:18 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:18 +0000] "GET /signalk/v1/api/tracks?radius=10000 HTTP/1.1" 304 - "http://sickiboat/@signalk/freeboard-sk/327.7a922d3e3f05f7c0.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:19 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:19 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:21 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:21 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:23 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:23 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:25 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:25 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:27 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:27 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:29 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:29 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:31 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:31 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:33 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:33 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" Apr 22 10:16:35 ::ffff:192.168.1.24 - - [22/Apr/2024:08:16:35 +0000] "POST /skServer/plugins/sksim/api HTTP/1.1" 200 37 "http://sickiboat/sksim/home" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"

DrStS commented 4 months ago

A call to the openweather API3 with my key gives this:

{"lat":39.099724,"lon":-94.578331,"tz":"-06:00","date":"2020-03-04","units":"standard","cloud_cover":{"afternoon":41.0},"humidity":{"afternoon":46.0},"precipitation":{"total":0.0},"temperature":{"min":278.31,"max":288.31,"afternoon":285.65,"night":281.56,"evening":286.21,"morning":279.67},"pressure":{"afternoon":1018.0},"wind":{"max":{"speed":5.5,"direction":233.0}}}

So I assume that the API works.

panaaj commented 4 months ago

So if you use your browser and go to: signalk/v2/api/meteo You should see an entry with the id freeboard-sk. That indicates that the fetch from Openweather was successful.

You should see data if you visit /signalk/v2/api/meteo/freeboard-sk/forecasts

DrStS commented 4 months ago

both of these api call render a empty response {}.

panaaj commented 4 months ago

No data was fetched. Turn on debugging in the Plugin Config screen. Screenshot_20240425-185730.png

The server console should have verbose logging of the fetch process for weather data.

DrStS commented 4 months ago

This the log Apr 25 15:35:14 2024-04-25T13:35:14.664Z @signalk/freeboard-sk GET /signalk/v2/api/meteo/:id/forecasts Apr 25 15:35:14 ::ffff:192.168.1.24 - - [25/Apr/2024:13:35:14 +0000] "GET /signalk/v2/api/meteo/freeboard-sk/forecasts HTTP/1.1" 304 - "http://sickiboat/@signalk/freeboard-sk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

panaaj commented 4 months ago

With Debug Log turned on, you should be seeing entries like the following in the log when a vessel position is available....

  @signalk/freeboard-sk *** Vessel position: {"longitude":5.4001780833333335,"latitude":53.20037115}. +1ms
  @signalk/freeboard-sk *** Weather: Calling service API.....(attempt: 1) +0ms
  @signalk/freeboard-sk Position: {"longitude":5.4001780833333335,"latitude":53.20037115} +0ms
  @signalk/freeboard-sk *** Weather: polling weather provider. +0ms
  @signalk/freeboard-sk *** Weather: data received.... +619ms
  @signalk/freeboard-sk **** METEO - emit deltas***** +0ms
  @signalk/freeboard-sk **** METEO ***** +0ms
  @signalk/freeboard-sk **** METEO OBS ***** +0ms
  @signalk/freeboard-sk **** SENDING METAS ***** +1ms
  @signalk/freeboard-sk **** METEO - build metas ***** +0ms
  @signalk/freeboard-sk **** METEO - building observation metas ***** +0ms

If you don't log entries like those above, then openweather is not being polled for data.

If there is no position available then lthe og entries will look like this....

 @signalk/freeboard-sk *** Weather: RETRY = 1 after no vessel position detected! +5s
 @signalk/freeboard-sk *** Weather: No vessel position detected! +0ms

Just to cover all bases, the PluginConfig should look like this.. and submit pressed to re-start the plugin. image

DrStS commented 4 months ago

Thanks! I have found the problem. If the plugin is enabled before the vessel pos is available than it does not fetch any data. Workaround: restart freeboard-sk. Yet I might think this is not the intended behavior?

panaaj commented 4 months ago

This is the intended behaviour.... it tries three times to retrieve the vessel position before "sleeping".... This is so if there is no internet connection it does not continuously try to poll. Re-starting the plugin after vessel position is available is the remediation.

martincaddick commented 3 months ago

I too am seeing 'No weather data found'. Debug log shows this so I know it is sort of getting there.

May 12 10:55:49 2024-05-12T10:55:49.073Z @signalk/freeboard-sk * Weather: data received.... May 12 10:55:49 2024-05-12T10:55:49.073Z @signalk/freeboard-sk * METEO - emit deltas May 12 10:55:49 2024-05-12T10:55:49.074Z @signalk/freeboard-sk METEO * May 12 10:55:49 2024-05-12T10:55:49.074Z @signalk/freeboard-sk METEO OBS * May 12 10:55:49 2024-05-12T10:55:49.074Z @signalk/freeboard-sk SENDING METAS * May 12 10:55:49 2024-05-12T10:55:49.074Z @signalk/freeboard-sk METEO - build metas * May 12 10:55:49 2024-05-12T10:55:49.074Z @signalk/freeboard-sk ** METEO - building observation metas ***

However, I am also logging my signalk data to an influxdb and I get this error.

May 12 10:56:44 ERROR: Write to InfluxDB failed. m [HttpError]: failure writing points to database: partial write: field type conflict: input field "value" on measurement "environment.forecast.temperature" is type float, already exists as type string dropped=5 at IncomingMessage. (/root/.signalk/node_modules/@influxdata/influxdb-client/dist/index.js:5:5671) at IncomingMessage.emit (node:events:529:35) at endReadableNT (node:internal/streams/readable:1400:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { statusCode: 422, statusMessage: 'Unprocessable Entity', body: '{"code":"unprocessable entity","message":"failure writing points to database: partial write: field type conflict: input field \"value\" on measurement \"environment.forecast.temperature\" is type float, already exists as type string dropped=5"}', contentType: 'application/json; charset=utf-8', json: { code: 'unprocessable entity', message: 'failure writing points to database: partial write: field type conflict: input field "value" on measurement "environment.forecast.temperature" is type float, already exists as type string dropped=5' }, code: 'unprocessable entity', _retryAfter: 0 } May 12 10:56:49 2024-05-12T10:56:49.074Z @signalk/freeboard-sk Weather: wake from sleep....poll provider. May 12 10:56:49 2024-05-12T10:56:49.074Z @signalk/freeboard-sk Wake timer watchdog -> OK May 12 10:56:49 2024-05-12T10:56:49.075Z @signalk/freeboard-sk Weather: Polling provider. May 12 10:56:49 2024-05-12T10:56:49.075Z @signalk/freeboard-sk *** Vessel position: ---- snip ----

panaaj commented 3 months ago

From the debug log the weather data has been fetched.

  1. Check the data browser in the SignalK server administrator admin UI.
  1. You should also be able to use your browser to view data at <your sk server>/signalk/v2/api/meteo/freeboard-sk
martincaddick commented 3 months ago

Does this mean it is having a problem uploading the position to meteo?

image

image

Under 'self'

image

-- log -- May 14 16:18:46 2024-05-14T16:18:46.173Z @signalk/freeboard-sk Weather: settings: {"enable":true,"apiVersion":3,"apiKey":"9da1d6d2560aad8e81aec946e0da810b","pollInterval":15} May 14 16:18:46 2024-05-14T16:18:46.173Z @signalk/freeboard-sk fetchInterval: 900000 May 14 16:18:46 2024-05-14T16:18:46.175Z @signalk/freeboard-sk Vessel position: {"latitude":47.31368637084961,"longitude":5.026662349700928,"altitude":240.39999389648438}. May 14 16:18:46 2024-05-14T16:18:46.176Z @signalk/freeboard-sk Weather: Calling service API.....(attempt: 1) May 14 16:18:46 2024-05-14T16:18:46.176Z @signalk/freeboard-sk Position: {"latitude":47.31368637084961,"longitude":5.026662349700928,"altitude":240.39999389648438} May 14 16:18:46 2024-05-14T16:18:46.177Z @signalk/freeboard-sk Weather: polling weather provider. May 14 16:18:46 POST /skServer/plugins/freeboard-sk/config 200 10.742 ms - 43 May 14 16:18:46 2024-05-14T16:18:46.805Z @signalk/freeboard-sk Weather: data received.... May 14 16:18:46 2024-05-14T16:18:46.805Z @signalk/freeboard-sk METEO - emit deltas* May 14 16:18:46 2024-05-14T16:18:46.806Z @signalk/freeboard-sk METEO * May 14 16:18:46 2024-05-14T16:18:46.806Z @signalk/freeboard-sk ** METEO OBS ***

panaaj commented 3 months ago

It appears that there is an issue parsing the data returned from OpenWeather. The position data is empty and this should reflect the values returned from OpenWeather.

You can try calling the API from your browser to see what is returned for your position....

https://api.openweathermap.org/data/3.0/onecall?lat=47.31368637084961&lon=5.026662349700928&exclude=minutely,daily&appid=<your_api_key>

martincaddick commented 3 months ago

Does this mean that using weather forecast in freeboard-sk requires a paid subscription to openweather? { "cod": 401, "message": "Please note that using One Call 3.0 requires a separate subscription to the One Call by Call plan. Learn more here https://openweathermap.org/price. If you have a valid subscription to the One Call by Call plan, but still receive this error, then please see https://openweathermap.org/faq#error401 for more info." }

panaaj commented 3 months ago

You need a V3 API key.

You have to register but only pay if you breach the free threshold for requests. Personally I have not breached the free threshold, so have not been billed.

You can set a maximum number of requests per hour in the user portal so you do not exceed the free limit. I suggest you do this as a failsafe.

By default the plugin makes 1 request every hour so there should be no issue with billing.

panaaj commented 3 months ago

As an FYI there is a weather API in development and a plugin to use open-meteo.

https://github.com/SignalK/signalk-server/pull/1733

martincaddick commented 3 months ago

Thanks for your patience, working well now. After signing up for the One Call API 3.0 plan I then needed to create a new API key. It still didn't work with the original key.