OpenWeatherMap-Alerts-Weather-Driver

I've changed it to write. Still can't read it.

[RELEASE]
V0.0.8
04/23/2020, #2

Changes:

  • Many bug fixes
  • Check for null values on OWM data and return Zero if a number of 'Unknown' if text.
  • Fix for Alerts where the API response reports back 200 ('Okay'), but the response data value is null.

Special 'Thanks!' to @CurtisZM for identifying bugs and helping with testing.

Have been quietly testing this, currently version 0.0.8 (04/23/2020-2) installed via Hubitat Package Manager, there are still errors in the following conditions or with options enabled:

TLDR; lines 402-404 hardcoded to the placeholder value of 0.00, commenting out the rest of the line resolves any errors having to do with precipitation, so the null check doesn't seem to be working

  • "Use Lux jitter control" == ON
    dev:1642020-04-24 04:40:58.130 am errorjava.lang.NullPointerException: Cannot invoke method toInteger() on null object on line 562 (updateLux) dev:1642020-04-24 04:40:58.111 am infoOpenWeatherMap.org Weather Driver - INFO: Calling UpdateLux(true)

  • always (lines 402 through 404 all produce this error, of course if i comment them out, line 405 produces an null value error since t_pN aren't there) If i comment out 402-408, it moves the errors. This is regardless of whether the precipitation or forecast options are on/off
    dev:1642020-04-24 04:50:48.842 am errorjava.lang.NullPointerException: Cannot invoke method toBigDecimal() on null object on line 402 (pollOWMHandler)
    dev:1642020-04-24 05:01:53.188 am [error]java.lang.NullPointerException: Cannot invoke method multiply() on null object on line 405 (pollOWMHandler)
    The nested ternary expressions make it a little difficult to review/troubleshoot.

line 402-404, the indexes in the null test owm.daily[0].rain==null are all [0] instead of [1], [2] for lines 403 and 404 respectively but the null test isn't working correctly anyway.

  • With lines 402-408 commented out AND Weather Summary==OFF (obviously missing the rainToday var), but line 643 falls outside of the if(weatherSummaryPublish) so the string is being built even though there's no need for it. This is just incidental/orthogonal.
    dev:1642020-04-24 05:09:33.877 am errorjava.lang.NullPointerException: Cannot invoke method toBigDecimal() on null object on line 643 (pollOWMHandler)
    Because the rainToday is missing, with line 643 moved within the condition, that's resolved.

Since some attributes' value generation are interconnected it would make sense before bothering with generating values, to just do a complete check on whether those values will be needed (i.e. before line 402 precipitation assignments: if(weatherSummaryPublish || dashSharpToolsPublish || dashSmartTilesPublish || myTilePublish || rainTodayPublish) ... and then before even proceeding with calculations, sanity check all the raw data values that will be used at once, so you can handle the nulls gracefully prior to type casting and set an "unknown" value for rainToday or any others that would cause errors down the line.

It might be useful to implement a schema transformation that both validates and assigns upstream api data to known keys and types prior to proceeding with generating any of the attributes according to enabled options. This way you can work with known quantities throughout the rest of the script instead of having to validate/check for nulls or other errant data throughout, If that makes sense.

This is a great driver, i'd be glad to contribute on github if that would be useful.

EDIT
here's the data i'm seeing in the device details (redacted coordinates):

mult_p: 1
dewpoint: 56
condition_icon_url: https://tinyurl.com/y6xrbhpf/31.png
forecastHigh: 92
noAlert: true
wind_gust: 6
cloud: 1
wind_bft_icon: wb2.png
sunRiseSet: {"results":{"sunrise":"2020-04-24T11:52:31+00:00","sunset":"2020-04-25T01:04:45+00:00","solar_noon":"2020-04-24T18:28:38+00:00","day_length":47534,"civil_twilight_begin":"2020-04-24T11:27:26+00:00","civil_twilight_end":"2020-04-25T01:29:49+00:00","nautical_twilight_begin":"2020-04-24T10:57:33+00:00","nautical_twilight_end":"2020-04-25T01:59:42+00:00","astronomical_twilight_begin":"2020-04-24T10:26:39+00:00","astronomical_twilight_end":"2020-04-25T02:30:37+00:00"},"status":"OK"}
humidity: 82
imgName2: <img class="centerImage" src=https://tinyurl.com/y6xrbhpf/32.png>
alertTileLink: <a href="https://forecast.weather.gov/MapClick.php?" target="_blank">No current weather alerts for this area.</a>
imgName0: <img class="centerImage" src=https://tinyurl.com/y6xrbhpf/31.png>
imgName1: <img class="centerImage" src=https://tinyurl.com/y6xrbhpf/32.png>
riseTime: 06:52
alertLink2: <a>Clear sky</a>
is_day2: true
setTime: 20:04
alertLink3: <a>Clear sky</a>
is_day1: true
vis: 10
alertLink: <a>Clear sky</a>
futime: Fri Apr 24 05:42:34 CDT 2020
is_day: false
pressure: 30
forecast_code: clear
tw_end: 20:29
illuminance: 5
forecast_code1: clear
forecast_code2: clear
day2: Sunday
bwn: Fully Night Time
wind_string: Light breeze from the Southwest at 6 MPH
forecastLow: 62
ddisp_twd: %3.0f
day1: Saturday
currDate: 2020-04-24
forecast_id: 800
wind: 6
condition_code: nt_clear
forecastLow1: 58
wind_degree: 230
forecastLow2: 58
city: Austin
is_light: false
mult_twd: 1
forecastHigh1: 78
forecastHigh2: 81
Summary_last_poll_date: 4/24/2020
riseTime2: 06:52
tw_begin: 06:27
localSunrise: 6:52 AM
forecast_text: Clear sky
alert: No current weather alerts for this area
iconType: true
riseTime1: 06:52
temperature: 61
currTime: 05:42
wind_cardinal: SW
wind_string_bft: Light breeze
forecast_text2: Clear sky
forecast_text1: Clear sky
localSunset: 8:04 PM
ddisp_p: %,4.0f
condition_text: Clear sky
ddisp_r: %2.0f
Summary_last_poll_time: 5:42 AM
wind_direction: Southwest
condition_id: 800
forecast_id2: 800
ultravioletIndex: 9.73
feelsLike: 60
forecast_id1: 800
OWN_icon: 01n
is_lightOld: false
fotime: Fri Apr 24 05:42:34 CDT 2020
iconLocation: https://tinyurl.com/y6xrbhpf/
noonTime: 13:28
illuminated: 5
setTime2: 20:04
setTime1: 20:04
possAlert: false
alertTile: Weather Alerts for <a href="https://forecast.weather.gov/MapClick.php?" target="_blank">Austin</a><br>updated at 5:42 AM on 4/24/2020.<br><a href="https://forecast.weather.gov/MapClick.php? target="_blank">No current weather alerts for this area.</a><br><a href="https://forecast.weather.gov/MapClick.php?" target='_blank'><img src=https://tinyurl.com/y6xrbhpf/NWS_240px.png style="height:2.0em;display:inline;"></a>
1 Like

@Matthew

Just wanted to ask why there would be such a difference in lux reading between this driver and the Dark- sky driver. Yesterday it was over 1000 lux difference. Currently it is 147 lux but as a percentage it is close to 20%

Lux

Weather service LUX is a best guess calculation, I would expect a variance from provider to provider.

I use LUX as part of my lighting automations, and wanted accurate hyper local information without depending on a cloud (unintended pun) based service provider. I now use an indoor Hue Motion Sensor with builtin Lux sensor pointing out my window attached with double sided tape. Quick response and it works great.

2 Likes

I do the same thing, but I'm using a couple of fibaro multi-sensors. One on the front window and one one the back. Most of my automations are based on the reading of one or the other or an average of both sensors. I find it much better than relying on sunset/sunrise or a reported "third party" lux value.

2 Likes

[UPDATED]
V0.0.9
04/24/2020

Changes:

  • Continue to work on improving null handling
  • various bug fixes.

See update V0.0.3 where many of these items are addressed.

Thanks.

1 Like

Trying to set this up and I'm getting some errors:

I'm running v0.0.8 as that is what was shown as current on Github. Not sure if you've pulled 0.0.9

Looks like I missed an important step of the update process, actually putting the new file out there. Sorry about that. The updated file is there now. I does attempt to address the errors you were seeing.

Works now. Thanks

1 Like

[UPDATED]
V0.1.0
05/07/2020

Changes:

  • Improved Alert handling for dashboard tiles, various bug fixes

PLEASE NOTE: after any update of the driver code, even if you use Hubitat Package Manager, you should open the virtual device, click 'Save Device', then click 'Save Preferences'.

I recently installed this app with the intent of moving away from Dark Sky app.

You've done a great job with this app, it looks and feels almost identical to it's Dark Sky predecessor.

I understand each provider may vary a bit from the other's information, but in my case it's more than I was expecting, and now I don't know which one is real, since both vary in some way from what I see out my window. Is anyone else seeing these variations?

Dark Sky
image

Open Weather
image

This also occurs with the 3 day forecast.

Yep. Different sources, different results. I actually setup a dashboard and have both the DS and OWM side-by-side. I would say the majority of the time, for me, they are reasonably close to one another. But, every once in a while, they are not reasonably close to one another. Temp and pressure seem to track closer than wind and precipitation. 'Condition' is close most of the time ('Few Clouds' vs 'Partly Cloudy'), but again, periodically it is significantly different ('Clear' vs 'Overcast'). I believe it largely depends on the accuracy of the weather stations in your area that DS/OWM are relying on to provide accurate data and how often they update those.

1 Like

I have looked for the docs for what goes into the field - Station Data File Location but can't locate it. What should I place here?

First of all, this thread is for the no PWS required version of the driver. It does not require Weather-Display and does not ask for the Station Data File Location. I am guessing you loaded the wrong driver version that requires a PWS and Weather-Display software.

The 'Station Data File Location' needs to the location of the 'clientraw.txt' data file that Weather-Display creates. It should be a URL like 'http://your_weather_website/' where the 'clientraw.txt file resides.

That driver requires the Weather-Display data files as its primary source, It can pull in from OpenWeatherMap forecast data to supplement that, but it will not work without access to the Weather-Display data files.

Read this post on how to expose the Weather-Display data files in JSON format... Weather-Display Driver

1 Like

Just installed using HPM but no driver appeared as far as I can see :cry:

Oh, stupid me. Found it in the driver page not the devices page. Duh.

@simple @Matthew does it support the rainToday attribute ?

Wiki is here.

Yes. It is an optional attribute. Make sure you turn it on then 'Save Preferences."

@Matthew

I have it enabled but it always shows as 0

image