Apixu.com worldwide weather data with outside lux. No PWS or server setup

unfortunately the free api key does not return some of the data hence the non working attributes.

i was going to use get sunrise and sunset data from the hub but that api does not seem to work in drivers. so sunrise/sunset/illuminance and forecast is not available on this.

i have posted on the hubitat support forum to see if the sunrise/sunset api can work in drivers. if it does some of the missing attributes could be filed in that way.

thanks for the link. does the WU driver work standalone or does it need the app to work?

ok. would you please consider adding an attribute with City, State? that seems to be one thing i use thats missing. and solar radiation is that a good approximation for lux? at my location there is no value for solar radiation however the light is still fairly bright outside.

thanks.

here is the city and state as was defined in the other driver "${obs.display_location.city}, ${obs.display_location.state}"

maybe make this configurable so there is no confusion between solar radiation and illuminance.

no worries ... get some sleep. :slight_smile:

thanks. that works.

since solar radiation is not always reported and its not typically the same as illuminance ... you could add a setting to have the user confirm if they want the value of solar radiation from the weather station published as illuminance. if user sets that flag as true via settings then publish the solar radiation as illuminance otherwise publish solar radiation as solar radiation and dont publish as illuminance.

since the illuminance capability is supported in the device and not all weather stations support returning solar radiation having an option not to publish solar radiation as illumination will prevent false triggers.

i was going to use this in the driver i had posted. this returns local sunrise and sunset in ISO 8601 format if you want to calculate illuminance based on this, current time and condition.

// attribution: sunrise and sunset data and api courtesy https://sunrise-sunset.org/
private getSunriseAndSunset()	{
    def params = [
        uri: "https://api.sunrise-sunset.org/json?lat=${location.latitude}&lng=${location.longitude}&date=today&formatted=0"
    ]
    
    def sunRiseAndSet = [:]
    
    try {
        httpGet(params)		{ resp ->
            sunRiseAndSet = [sunrise: resp.data.results.sunrise, sunset: resp.data.results.sunset]
        }
    } catch (e) {
        log.error "http call failed for sunrise and sunset api: $e"
    }

    // returns map with sunrise and sunset in ISO8601 format example: [sunrise:2018-05-01T13:11:41+00:00, sunset:2018-05-02T02:58:41+00:00]
    return sunRiseAndSet
}

the site uses rate limiting so might be worth calling this only when the date changes to a new date.

Just as a heads up for anyone looking into this. currently (5/18/18) you can not get a free API key from WU any more. It looks like as long as you have a key you'll be ok for a while, but no new keys are being given out.

1 Like

fyi i am planning to switch this over to Weather API - OpenWeatherMap using the current weather API.
OR
Current Weather API - API Doc | Apixu.com
OR
Weather Unlocked API - Local Weather Pricing Plans

i was also thinking of trying noaa.gov but their weather api seems unreachable.

got to experiment a little with which one works best.

2 Likes

what endpoints are you trying for NOAA?

i had seen these last time looking for weather API back in 2017 ... the website seems unavailable now ... maybe someone at .gov doesnt like sharing weather data any more.

heres the archive link:

https://web.archive.org/web/20180125084701/www.ncdc.noaa.gov/cdo-web/webservices/v2#dataTypes

going to go with apixu. of the other 2 didnt like how they handle rate limiting on one and their limited international support on the other.

going to just push all of the attributes they support as is with the same name:

{
    "location": {
        "name": "Kolkata",
        "region": "West Bengal",
        "country": "India",
        "lat": 22.57,
        "lon": 88.37,
        "tz_id": "Asia/Kolkata",
        "localtime_epoch": 1526680245,
        "localtime": "2018-05-19 3:20"
    },
    "current": {
        "last_updated_epoch": 1526679924,
        "last_updated": "2018-05-19 03:15",
        "temp_c": 25.0,
        "temp_f": 77.0,
        "is_day": 0,
        "condition": {
            "text": "Mist",
            "icon": "//cdn.apixu.com/weather/64x64/night/143.png",
            "code": 1030
        },
        "wind_mph": 0.0,
        "wind_kph": 0.0,
        "wind_degree": 0,
        "wind_dir": "N",
        "pressure_mb": 1002.0,
        "pressure_in": 30.1,
        "precip_mm": 1.3,
        "precip_in": 0.05,
        "humidity": 83,
        "cloud": 75,
        "feelslike_c": 27.3,
        "feelslike_f": 81.1,
        "vis_km": 3.2,
        "vis_miles": 1.0
    }
}

will also:

  • change everything to valuetile since this is for hubitat only
  • add an attribute called location in city, state format
  • add a calculated attribute for illumination

havent checked. i am doing this for folks like me that dont own a pws.

Not that I can find

I think that an app can be written to cover both needs ... as long as the data end point is configurable / mappable

Those of us running our own PWS should be able to create a json file for consumption, based on a template, using the naming the driver expects.

The Driver then has a config option - JSON or
If JSON then input the URL for the file
pseudocode:

if selected.jsonfile then
GET json.url/file.json
else
Call API functions

Then the app/driver can support multiple options, even multiple APIs as long as the author wants to go through that nightmare of support churn :slight_smile:

1 Like

did you just self nominate to write the app? :smile:

thanks for doing this. however as posted earlier on this thread ... i am still planning on sharing a driver for apixu.com ... something that works for use cases that i have in mind.

since this one will not work for that purpose and so users dont get confused ... would you mind removing this from here and posting it on one of your other threads?

thank you.

o i wouldnt be concerned about that. its about the user experience. need to be able to provide something that works for other users like myself without pws and outdoor lux sensors. :slight_smile:

thank you.

Did you complete the driver yet?
I’m interested to see the outcome

sorry got distracted with some ST issues. will probably put out the first version this weekend.

first version is done ... going to check the illuminance calculation a bit more ... not intended to be scientific but should be consistent relatively. there is a bit more to do in deriving illuminance ... specially on rainy or snowy days ... will work on that for the next version.

this dashboard only shows some of the attributes available in the driver ... there are some more that apixu returns that i am not publishing yet but if someone has a use for them will be happy to start publishing those as well.

when i post the driver will also post all of the attributes available from apixu so you can see what else may be available.

4 Likes