コード例 #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the BOM weather platform."""
    station = config.get(CONF_STATION) or closest_station(
        config.get(CONF_LATITUDE), config.get(CONF_LONGITUDE),
        hass.config.config_dir)
    if station is None:
        _LOGGER.error("Could not get BOM weather station from lat/lon")
        return False
    bom_data = BOMCurrentData(hass, station)
    try:
        bom_data.update()
    except ValueError as err:
        _LOGGER.error("Received error from BOM_Current: %s", err)
        return False
    add_devices([BOMWeather(bom_data, config.get(CONF_NAME))], True)
コード例 #2
0
ファイル: bom.py プロジェクト: boced66/home-assistant
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the BOM weather platform."""
    station = config.get(CONF_STATION) or closest_station(
        config.get(CONF_LATITUDE),
        config.get(CONF_LONGITUDE),
        hass.config.config_dir)
    if station is None:
        _LOGGER.error("Could not get BOM weather station from lat/lon")
        return False
    bom_data = BOMCurrentData(station)
    try:
        bom_data.update()
    except ValueError as err:
        _LOGGER.error("Received error from BOM_Current: %s", err)
        return False
    add_entities([BOMWeather(bom_data, config.get(CONF_NAME))], True)