Skip to content

Commit

Permalink
Fix null values, send timeout as meta
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrofta committed Apr 20, 2021
1 parent fec8859 commit cb6e700
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ Install the plugin through the SignalK plugin interface. After installation you
'environment.forecast.humidity'<br><br>
'environment.forecast.pressure'<br><br></code><br>
</p>
<p>Forecast data is purely based on position - hence <code>'navigation.position'</code> needs to present. Data will be queried on position change and/or regularily on an hourly-basis (triggered by signalk-raspberry-pi-temperature-plugin). <code>'navigation.gnss.antennaAltitude'</code> (GPS altitude) is required if operated on non-sealevel altitude to compensate atmospheric pressure data to the appropriate elevation. Plugins like signalk-fixedstation could be used and the plugin will make calculations by adjusting the pressure accordingly. Default is altitude = 0 (sea level).It will take the plugin a few minutes before showing output data, as it will need to collect position information before requesting data from openweathermap.</p><br>
By default the will update forecast information every hour. No information will be stored or tracked.<br>
Note: Alerts from openweathermap.org currently not implemented as based on <code>'environment.outside.pressure'</code> like provided by RuuviTag severities could be more accurate and it's possible to set an alarm, i.e. via the Simple Notification-plugin.<br>
<p>Forecast data is purely based on position - hence <code>'navigation.position'</code> needs to be present. Data will be queried on position change and/or regularily on an hourly-basis (triggered by signalk-raspberry-pi-temperature-plugin). <code>'navigation.gnss.antennaAltitude'</code> (GPS altitude) is required if operated on non-sealevel altitude to compensate atmospheric pressure data to the appropriate elevation. Plugins like signalk-fixedstation could be used and the plugin will make calculations by adjusting the pressure accordingly. Default is altitude = 0 (sea level).It will take the plugin a few minutes before showing output data, as it will need to collect position information before requesting data from openweathermap.</p><br>
By default the plugin will update forecast information every hour. No information will be stored or tracked.<br>
Note: Alerts from openweathermap.org currently not implemented as based on <code>'environment.outside.pressure'</code> like provided by RuuviTag. Severities could be more accurate and it's possible to set an alarm, i.e. via the Simple Notification-plugin.<br>

## Details on input data
<p>Simple output format is based on openweather-apis SMART JSON<br>
Expand Down Expand Up @@ -57,4 +57,6 @@ Note: Alerts from openweathermap.org currently not implemented as based on <code
</code></p>

The plugin shall adhere to meta-data units according to the SignalK definition.
Note (v0.5): To comply with the SignalK spec timestamps are provided according to RFC3339.
### Release Notes
- v0.5: Comply with the SignalK spec by providing timestamps according to RFC3339.
- v0.6: Support value timeouts according to the SignalK spec
44 changes: 22 additions & 22 deletions openweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,42 +235,42 @@ function onElevationUpdate(value) {
}

function prepareUpdate(forecast, weather, full) {
const noData = "waiting ..."
const noVal = null
const noData = "waiting ..." // only sending for "description"
const noVal = null // sending null until data is available
switch (type) {
case 'simple': return [
buildDeltaUpdate(forecastTime, forecast.time !== null ? convert.toSignalK('unixdate', forecast.time).value : noData),
buildDeltaUpdate(forecastTime, forecast.time !== null ? convert.toSignalK('unixdate', forecast.time).value : noVal),

buildDeltaUpdate(simpleDescription, weather.description !== null ? weather.description : noData),
buildDeltaUpdate(simpleTemp, weather.temp !== null ? weather.temp : noVal),
buildDeltaUpdate(simpleTemp, weather.temp),
buildDeltaUpdate(simpleHumidity, weather.humidity !== null ? convert.toSignalK('%', weather.humidity).value : noVal),
buildDeltaUpdate(simplePressure, weather.pressure !== null ? weather.pressure : noVal),
buildDeltaUpdate(simplePressure, weather.pressure),
buildDeltaUpdate(simpleRain, weather.rain !== null ? weather.rain : {}),
buildDeltaUpdate(simpleWeatherCode, weather.weathercode !== null ? weather.weathercode : noVal)
buildDeltaUpdate(simpleWeatherCode, weather.weathercode)
];
case 'full': return [
buildDeltaUpdate(forecastTime, forecast.time !== null ? convert.toSignalK('unixdate', forecast.time).value : noData),
buildDeltaUpdate(forecastSunrise, forecast.sunrise !== null ? convert.toSignalK('unixdate', forecast.sunrise).value : noData),
buildDeltaUpdate(forecastSunset, forecast.sunset !== null ? convert.toSignalK('unixdate', forecast.sunset).value : noData),
buildDeltaUpdate(forecastTime, forecast.time !== null ? convert.toSignalK('unixdate', forecast.time).value : noVal),
buildDeltaUpdate(forecastSunrise, forecast.sunrise !== null ? convert.toSignalK('unixdate', forecast.sunrise).value : noVal),
buildDeltaUpdate(forecastSunset, forecast.sunset !== null ? convert.toSignalK('unixdate', forecast.sunset).value : noVal),

buildDeltaUpdate(simpleDescription, weather.description !== null ? weather.description : noData),
buildDeltaUpdate(fullIcon, forecast.icon !== null ? forecast.icon : noVal),
buildDeltaUpdate(fullMain, forecast.main !== null ? forecast.main : noVal),
buildDeltaUpdate(fullIcon, forecast.icon),
buildDeltaUpdate(fullMain, forecast.main),

buildDeltaUpdate(simpleTemp, weather.temp !== null ? weather.temp : noVal),
buildDeltaUpdate(fullTempMin, full.temp.min !== null ? full.temp.min : noVal),
buildDeltaUpdate(fullTempMax, full.temp.max !== null ? full.temp.max : noVal),
buildDeltaUpdate(fullFeelsLike, full.feelslike !== null ? full.feelslike : noVal),
buildDeltaUpdate(simplePressure, weather.pressure !== null ? weather.pressure : noVal),
buildDeltaUpdate(simpleTemp, weather.temp),
buildDeltaUpdate(fullTempMin, full.temp.min),
buildDeltaUpdate(fullTempMax, full.temp.max),
buildDeltaUpdate(fullFeelsLike, full.feelslike),
buildDeltaUpdate(simplePressure, weather.pressure),
buildDeltaUpdate(simpleHumidity, weather.humidity !== null ? convert.toSignalK('%', weather.humidity).value : noVal),
buildDeltaUpdate(fullDewPoint, full.dewpoint !== null ? full.dewpoint : noVal),
buildDeltaUpdate(fullUVIndex, full.uvindex !== null ? full.uvindex : noVal),
buildDeltaUpdate(fullClouds, full.clouds !== null ? full.clouds : noVal),
buildDeltaUpdate(fullVisibility, full.visibility !== null ? full.visibility : noVal),
buildDeltaUpdate(fullWindSpeed, full.wind.speed !== null ? full.wind.speed : noVal),
buildDeltaUpdate(fullDewPoint, full.dewpoint),
buildDeltaUpdate(fullUVIndex, full.uvindex),
buildDeltaUpdate(fullClouds, full.clouds),
buildDeltaUpdate(fullVisibility, full.visibility),
buildDeltaUpdate(fullWindSpeed, full.wind.speed),
buildDeltaUpdate(fullWinDir, full.wind.dir !== null ? convert.toSignalK('°', full.wind.dir).value : noVal),
buildDeltaUpdate(simpleRain, weather.rain !== null ? weather.rain : {}),
buildDeltaUpdate(simpleWeatherCode, weather.weathercode !== null ? weather.weathercode : noVal)
buildDeltaUpdate(simpleWeatherCode, weather.weathercode)
];
case 'meta-simple': return [
buildDeltaUpdate(simpleTemp, { units: "K" }),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openweather-signalk",
"version": "0.5.2",
"version": "0.6.0",
"description": "SignalK plugin to provide data from OpenWeather Service",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cb6e700

Please sign in to comment.