[PROJECT] Driver for Ambient API/Local and Ecowitt

Changes are for ObserverIP "Live Data Scrape" functionality. Nobody else should see any difference in how their data is reported EXCEPT the last entry on UV.

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.4

Change(s):

  • LiveData was being attempted using HTTPS but the ObserverIP is only set for HTTP so this has been switched.
  • Eliminated most cases of making variable names based on their data field name (it.key) because of different names being received causing trouble. These have been switched with specifically set variable names now.
  • UVI values of 30 and above will be ignored. Since the highest registered during scientific studies happened at very specific locations on the planet and only reached 25. Ultraviolet readings will also only be referenced as uvi (or ultravioletIndex) now.
1 Like

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.5

Change(s):

  • Additional field name "windspeed" accepted because the actual ObserverIP data did not follow it's own example page for field names.

Looks like the final tweak on this one... changes should only be useful to someone using the Live Data Scrape method.
Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.6

Change(s):

  • Tweak to how the livedata was being polled due to a change in newer Hubitat firmware.
  • "uv" data from a Live Data Scrape will be ignored and instead the "uvi" value will be used in all cases due to the fact that livedata includes both and the "uv" value has not been found to really match anything useful.

Found a word flip in variables when trying to create a rain sensor logic in the case on lines 976 to 985:

			case "rainratein":
				ProcessState( "rainratein", it.value as float )
				if( MeasurementStandard == "Metric" ){
					ProcessEvent( "RainRate", ConvertInches( "Imperial", state.raterainin ), "mm" )
					PostEventToChild( "Outdoor Station", "RainRate", state.RainRate, "mm" )
				} else {
					ProcessEvent( "RainRate", state.raterainin, "in" )
					PostEventToChild( "Outdoor Station", "RainRate", state.RainRate, "in" )
				}
				break

I've validated switching state.raterainin to state.rainratein gets RainRate to report correctly.

Thanks for the great work!

Confirmed, lines 979 and 982 had the wrong state name... This has also been this way for a LONG time it appears. Corrected version will be posted in a couple minutes (not much testing needed for this).

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.7

Change(s):

  • Corrected references for rainrate state names. Thanks to @sid1 for pointing out this error.
  • Added Runtime state data if returned (it showed up on my Ecowitt gateway at least). This gets converted from the number of seconds to a "human-readable" string like X Days Y Hours and Z Minutes.
1 Like

Great! Took me over 3 weeks to find it.

Nice on runtime data. My Ecowitt gateway shows it as well. I also have a soil sensor that I don't use the gateway is returning unhandled data:

GW1000B - Unhandled data: soilad1 = 324

I don't use it and haven't dug into.

Thanks again!

I had no idea what soilad was... but I found ONE reference to a WXForum Thread in Google searches and it actually matches(!).

It appears soilad1..8 is returning the soil sensors calibration value. That is it. It has no apparent value as the calibrated values from the soil sensor are already returned and the calibration was set in the app.

So... the next time I am making an edit I will try to include it in the "state variable only" section of data. Interestingly enough, it is not in the data returned for my soil sensor. I will have to check if I have the latest version of the firmware for everything...

Thanks for letting me know! That is exactly the reason I flag "Unhandled data" in case someone sees something potentially valuable that I can start capturing.

1 Like

Yep, I found the same thing recently, they are the calibration settings.

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.8

Change(s):

  • Added in the soilad# for recognition so that these can be properly handled.
  • Made some changes to the driver attribute names. They were changed from "Driver Name" to "DriverName", "Driver Version" to "DriverVersion", and "Driver Status" to "DriverStatus". This is to eliminate a couple of the visual glitches on a device's page if those are updated (because they have spaces in them). Unfortunately it is tough for me to fix this problem overall as I would have to overhaul almost all attributes I currently use and I do not want to break whatever Rules and uses people are already using them for. So I am starting to change a couple most people likely would not even notice otherwise and handling it with completely new projects as I make them.

Hi Getting errors on the HPM trying to update the Ambient Weather Application on Hubitat

An error occurred while installing the package: Failed to install app https://raw.githubusercontent.com/KurtSanders/STAmbientWeather/master/hubitat/smartapps/kurtsanders/ambient-weather-station.src/ambient-weather-station.groovy. Please notify the package developer..

That is not my driver... so I cannot help you there. None of my drivers are on github, although they are in HPM (they are linked to my own server). I think you want this thread.

UPDATE:
I see you got this resolved in another thread. Glad it worked out.

1 Like

Thanks @snell

Hi @snell. I've noticed the ambient station is no longer updating after working as expected for a couple years. Tried reinstalling the driver and adding the virtual driver again. This error is repeated in the logs. Using the Ambient Local method for the data and confirmed the host IP is set to the C7 Hub. Is there something else to try or look at?

2024-02-06 04:48:55.515 PMerrorjava.lang.ArrayIndexOutOfBoundsException: 1 on line 641 (method parse)

Assuming you have the latest version of the drivers... That error would prevent it from updating because that is in the steps to get the data ready for processing for an Ambient Local (it also proves you have the Ambient set up to go to the correct place). So... now on to troubleshooting:

  1. On the Ambient side (just to confirm the Custom/Customized destination), does it have the correct path and protocol? It should be trying to send it to /data/report as an Ambient method (sometimes labeled AMBWeather).
  2. Also on the Ambient side, have you checked for any firmware updates for your Ambient system?
  3. Assuming neither of those help... there could be a "flaw" or oddity in the reported data that I have not handled yet (not sure how it would not have crept up before this but it happens). Could you set the parent device to "Trace" logging and send me the resulting logs (in a separate message, not posted to the thread) when it receives the data from the weather station? They should start with:
    Raw data =
    Ambient Local Headers =
    Ambient Local rawData Step 1
    Ambient Local rawData Step 2 =

Maybe I can spot something in there and account for it going forward.

As a general note, I am using Ambient Local also (I actually still have mine working after all these years although I had to do another battery replacement this winter). I have an Ambient WS-2902A and the reported firmware I see in the WSView app is Version 4.3.4.

Thank you @snell for the information. They are great weather stations. Upgraded a few years ago to the ws-5000.

The driver is version 0.8.8 and use Package Manager to update it.

The weather station was on v1.7.4 and now updated to the latest 1.9.0.

The trace logs are enabled but still only showing the same error.
2024-02-09 08:14:46.780 PMerrorjava.lang.ArrayIndexOutOfBoundsException: 1 on line 641 (method parse)

That is strange because the "Raw data" should be posted to the log (when Trace logging is enabled) BEFORE it gets to the function that is getting the error. In fact, there should be multiple entries in the log:
Raw data...
Ambient Local Headers...
Ambient Local rawData Step 1...
Ambient Local rawData Step 2...

THEN it gets to the parseURLParameters which contains line 641...

Considering the error and the portion of code, my guess is that a data point is being returned that has a name but no value (ex: "lightning_time="). But without seeing the raw data returned I cannot confirm that.

@bertabcd1234: This is actually a section of code you provided me. Do you have any recommendation for what might be happening to cause @dmorehead1988's error? For reference (it has been a while) I have copied the code below, and the error is happening at the line that corresponds to URLDecoder.decode(it.split("=")[1])] })

// parses parameters received. This code is from @bertabcd1234
Map parseURLParameters(String parameters) {
      List keysAndVals = parameters.contains("&") ? parameters.split("&") : []
      Map data = keysAndVals.collectEntries( { [(URLDecoder.decode(it.split("=")[0])):
                                             URLDecoder.decode(it.split("=")[1])] })
      return data
}

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.9

Change(s):

  • Added a check for when Ambient Local data is provided. It turns out that in at least one instance (per @dmorehead1988's issue) the station can return the data with an unexpected data separator. Basically, it was adding an "&" at the beginning of the data (the & is used in the data to separate between different returned fields, so the extra was causing things to break). A check has been added to remove the extra character before continuing to process the data normally.

Updated Version(s):

  • AmbientEcowittWeather.groovy = 0.8.10
  • WeatherSensorChild.groovy = 0.8.14

Change(s):

  • Correction in the ProcessEvent function in the drivers.
  • Replaced driver-specific attributes "Device Name", "Device Version", and "Device Status" with ones that do not have spaces. They will be removed from the device the next time Save Preferences is run.