TheToddLuci0 / tomorrow_io

Wrapper for https://tomorrow.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License: MIT Code style: black

Tomorrow_io

Provides a wrapper layer for interfacing with Tomorrow.io. This is not an official package, and is primarily written for use in HomeAssistant plugins.

Usage

You will need to get an API key from Tomorrow.io. Sign up, then navigate to the keys page to get your API key. Note that the free plan limits you to 500 requests/day and 25 requests/hour.

Once you have an API key, you can simply create a Tomorrow object, and start pinging the API. A few examples follow.

Examples

Defaults

By default, the package assumes you want to know about Iowa State University. You can change that by passing the longitude and latutude arguments to any of Tomorrow's functions. To set your own defaults, pass them to the __init__ call. For prettymuch everything else, it assumes you want to follow Tomorrow.io's defaults, from their API docs.

Get the current temperature

from tomorrow_io import Tomorrow

apikey = 'YOUR_API_KEY'

tomorrow = Tomorrow(apikey)
tomorrow.get_current(data_fields=['temperature'])

Set a default location

from tomorrow_io import Tomorrow

apikey = 'YOUR_API_KEY'

# Check in on the Hawkeyes, may they always have rain on gameday!
tomorrow = Tomorrow(apikey, longitude=-91.5549009294, latitude=41.6626978351)
tomorrow.get_current(data_fields=['weatherCode'])

Note that we can still override the default location by passing latitude and/or longitude any of the functions of Tomorrow.

data_fields

To get the information you want, you have to ask for it. Tomorrow.io supports numerous data fields, so I won't list them all, but some of the most common ones are below. A full list can be found here

temperature
temperatureApparent
humidity
precipitationProbability
precipitationType
cloudCover
weatherCode
epaIndex
epaHealthConcern
weedIndex
grassIndex
treeIndex

FAQ

Why bother with this though? Aren't API calls pretty easy?

Yep. The only real reason this exists is to facilitate Home Assistant plugin development. They require that API calls be wrapped in a library, available on PyPi. Source

Why black? That makes all this code look really dumb!

Yeah, I agree. Trying it out, since the Home Assistant project uses it, and I figured I should get used to it.

Pip install fails with file not foud: setup.py or similar

Your pip is out of date. pip install --upgrade pip (requires at least pip version 19, link)

This FAQ seems like a list of reasons not to use this

Yes it does, doesn't it?

About

Wrapper for https://tomorrow.io

License:MIT License


Languages

Language:Python 100.0%