How to use pynws - 1 common examples

To help you get started, we’ve selected a few pynws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github home-assistant / home-assistant / homeassistant / components / nws / weather.py View on Github external
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up the NWS weather platform."""

    latitude = config.get(CONF_LATITUDE, hass.config.latitude)
    longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
    station = config.get(CONF_STATION)
    api_key = config[CONF_API_KEY]
    mode = config[CONF_MODE]

    websession = async_get_clientsession(hass)
    # ID request as being from HA, pynws prepends the api_key in addition
    api_key_ha = f"{api_key} homeassistant"
    nws = SimpleNWS(latitude, longitude, api_key_ha, mode, websession)

    _LOGGER.debug("Setting up station: %s", station)
    try:
        await nws.set_station(station)
    except ERRORS as status:
        _LOGGER.error(
            "Error getting station list for %s: %s", (latitude, longitude), status
        )
        raise PlatformNotReady

    _LOGGER.debug("Station list: %s", nws.stations)
    _LOGGER.debug(
        "Initialized for coordinates %s, %s -> station %s",
        latitude,
        longitude,
        nws.station,

pynws

Python library to retrieve observations and forecasts from NWS/NOAA

MIT
Latest version published 6 days ago

Package Health Score

69 / 100
Full package analysis

Popular pynws functions

Similar packages