[PROJECT] Driver for Ambient API/Local and Ecowitt

I read that for sunlight, lux is approximately equal to solar radiation in w/m^2 * 127, so for a nominal max of 1kW/m^2 sunlight at the equator, illuminance would be about 127000.

Hubitat's UI for illuminance values appears to support a long integer, not a float. I added "as long" to the illuminance sending line:

sendEvent( name: "illuminance", value: state.illuminance as Long, unit: "lux",.........

and the illuminance value seems to be working fine with Hubitat now.

The official calculation that Ambient Weather uses on their backend for use in their Dashboard and for their console displays is:

lux = round(wm2 / 0.0079, 0)

wm2 = solarradation value from the API
divided by 0.0079 with 0 decimals rounded to the nearest integer

I do say "official" as I'm an integration partner with Ambient Weather and that is the calculation they provided to me.

3 Likes

Looks like I have what to do. I used a calculation I found that is *126.7 and the attribute itself was just defined as a number. Guess I should change it to be more specific. Thanks for all the feedback folks.

3 Likes

The most important thing I get out of this is that people are actively using my driver. Hoorah! Thanks everyone!

3 Likes

Thanks very much for sharing your driver! I really appreciate it.

1 Like

Updated version 0.91 is now posted with the illuminance value changed to be "as Long" and "/ 0.0079" method versus the "* 126.7" I had before. The number no longer contains a decimal but because it is night I only get a 0 value so tough to test much.

Thanks to @deane.gardner for point this problem out and @jeubanks for the calculation change.

If anyone notices any other things like this, please let me know.

2 Likes

Your linked file seems to be still revision 0.9?

This link has .91.

https://www.drdsnell.com/projects/hubitat/drivers/AmbientWeather.groovy

The links go to the same place (they are identical)... Maybe a browser refresh issue? When I click on either I get the correct one and I also copied both URLs to check them. I tried editing my original one just to check if there was something weird but could not find anything strange about the link.

Whoops, it was a browser refresh issue. Thanks again for the great driver and your help!

1 Like

Better safe than sorry so I appreciate the check.

1 Like

@snell I am getting the following error continuously. Appears in log about every minute. I haven't changed any of the credentials. What is it trying to tell me?

dev:24672019-12-09 09:15:04.089 am errorAmbient Weather - Error connecting to AmbientWeather: 429

Rate Limiting

API requests are capped at 1 request/second for each user's apiKey and 3 requests/second per applicationKey. When this limit is exceeded, the API will return a 429 response code.

Is that a problem with the driver then?

It's telling you there are too many requests to the API from a single API Key or APP Key. Are you using the same key from multiple apps/plugins? If so don't do that. Use a separate API Key.

1 Like

Ok, I am doing that so I will change that, thanks.

@jeubanks I changed the API to a different one for each hub. I am now getting this error on all hubs.

dev:24672019-12-09 11:21:03.501 am errorAmbient Weather - Error connecting to AmbientWeather: 401

I have found that if you have your data refresh rate set lower than every 5 minutes you will occasionally get the errors from too many requests to the API.

1 Like

Just like @waynespringer79 mentioned, cannot really recommend going more often than a poll per 5 minutes.

Also, as discussed higher up in the thread also, the API itself does not have refreshed data as often as you might want. So if you go faster, you will likely just see repeated data.

I changed to 5 but what seemed to help stop the constant errors was to give each ambient weather driver a separate API number from the website. Making each hub independent, API wise.

1 Like