'lightning-rainy': [200, 201, 202, 230, 231, 232], 'partlycloudy': [801, 802, 803], 'pouring': [504, 314, 502, 503, 522], 'rainy': [300, 301, 302, 310, 311, 312, 313, 500, 501, 520, 521], 'snowy': [600, 601, 602, 611, 612, 620, 621, 622], 'snowy-rainy': [511, 615, 616], 'sunny': [800], 'windy': [905, 951, 952, 953, 954, 955, 956, 957], 'windy-variant': [958, 959, 960, 961], 'exceptional': [711, 721, 731, 751, 761, 762, 771, 900, 901, 962, 903, 904], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the OpenWeatherMap weather platform.""" import pyowm longitude = config.get(CONF_LONGITUDE, round(hass.config.longitude, 5)) latitude = config.get(CONF_LATITUDE, round(hass.config.latitude, 5)) name = config.get(CONF_NAME) try: owm = pyowm.OWM(config.get(CONF_API_KEY)) except pyowm.exceptions.api_call_error.APICallError:
from homeassistant.helpers.storage import STORAGE_DIR from . import Gismeteo from .const import (ATTRIBUTION, DEFAULT_NAME, MIN_TIME_BETWEEN_UPDATES, CONF_CACHE_DIR, VERSION, FORECAST_MODE_HOURLY, FORECAST_MODE_DAILY) _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_MODE, default=FORECAST_MODE_HOURLY): vol.In([FORECAST_MODE_HOURLY, FORECAST_MODE_DAILY]), vol.Optional(CONF_CACHE_DIR): cv.string, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Gismeteo weather platform.""" name = config.get(CONF_NAME) latitude = config.get(CONF_LATITUDE, round(hass.config.latitude, 6)) longitude = config.get(CONF_LONGITUDE, round(hass.config.longitude, 6)) cache_dir = config.get(CONF_CACHE_DIR, hass.config.path(STORAGE_DIR)) mode = config.get(CONF_MODE)
from homeassistant.helpers.event import ( async_call_later, async_track_utc_time_change) import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) ATTRIBUTION = "Weather forecast from met.no, delivered by the Norwegian " \ "Meteorological Institute." DEFAULT_NAME = "Met.no" URL = 'https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Inclusive(CONF_LATITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.latitude, vol.Inclusive(CONF_LONGITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.longitude, }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Met.no weather platform.""" elevation = config.get(CONF_ELEVATION, hass.config.elevation or 0) latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) name = config.get(CONF_NAME) if None in (latitude, longitude): _LOGGER.error("Latitude or longitude not set in Home Assistant config")
import logging import voluptuous as vol from homeassistant.components.weather import PLATFORM_SCHEMA, WeatherEntity from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS from homeassistant.helpers import config_validation as cv # Reuse data and API logic from the sensor implementation from .sensor import CONF_STATION, BOMCurrentData, closest_station, validate_station _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_STATION): validate_station }) 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()
'lightning': [37], 'lightning-rainy': [3, 4, 38, 39, 47], 'partlycloudy': [44], 'pouring': [40, 45], 'rainy': [9, 11, 12], 'snowy': [8, 13, 14, 15, 16, 41, 42, 43], 'snowy-rainy': [5, 6, 7, 10, 46], 'sunny': [32, 33, 34, 25, 36], 'windy': [24], 'windy-variant': [], 'exceptional': [0, 1, 2], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_WOEID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Yahoo! weather platform.""" from yahooweather import get_woeid, UNIT_C, UNIT_F unit = hass.config.units.temperature_unit woeid = config.get(CONF_WOEID) name = config.get(CONF_NAME) yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F # If not exists a customer WOEID/calculation from Home Assistant if woeid is None:
def validate_station(station): """Check that the station ID is well-formed.""" if station is None: return if not re.fullmatch(r"[A-Z]{2}/s0000\d{3}", station): raise vol.error.Invalid('Station ID must be of the form "XX/s0000###"') return station PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_STATION): validate_station, vol.Inclusive(CONF_LATITUDE, "latlon"): cv.latitude, vol.Inclusive(CONF_LONGITUDE, "latlon"): cv.longitude, vol.Optional(CONF_FORECAST, default="daily"): vol.In(["daily", "hourly"]), }) # Icon codes from http://dd.weatheroffice.ec.gc.ca/citypage_weather/ # docs/current_conditions_icon_code_descriptions_e.csv ICON_CONDITION_MAP = { ATTR_CONDITION_SUNNY: [0, 1], ATTR_CONDITION_CLEAR_NIGHT: [30, 31], ATTR_CONDITION_PARTLYCLOUDY: [2, 3, 4, 5, 22, 32, 33, 34, 35], ATTR_CONDITION_CLOUDY: [10], ATTR_CONDITION_RAINY: [6, 9, 11, 12, 28, 36], ATTR_CONDITION_LIGHTNING_RAINY: [19, 39, 46, 47],
'lightning-rainy': [20, 23], 'partlycloudy': [2, 3], 'pouring': [8, 11], 'rainy': [6, 7, 9, 10, 12, 13, 14, 15], 'snowy': [18], 'snowy-rainy': [], 'sunny': [1], 'windy': [], 'windy-variant': [], 'exceptional': [], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the ipma platform.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) if None in (latitude, longitude): _LOGGER.error("Latitude or longitude not set in Home Assistant config")
'lightning-rainy': [38, 39], 'partlycloudy': [44], 'pouring': [40, 45], 'rainy': [9, 11, 12], 'snowy': [8, 13, 14, 15, 16, 41, 42, 43], 'snowy-rainy': [5, 6, 7, 10, 46, 47], 'sunny': [32], 'windy': [24], 'windy-variant': [], 'exceptional': [0, 1, 2, 3, 4, 25, 36], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_WOEID, default=None): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_FORECAST, default=0): vol.All(vol.Coerce(int), vol.Range(min=0, max=5)), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Yahoo! weather platform.""" from yahooweather import get_woeid, UNIT_C, UNIT_F unit = hass.config.units.temperature_unit woeid = config.get(CONF_WOEID) forecast = config.get(CONF_FORECAST) name = config.get(CONF_NAME) yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F
92: "fog", # "Fog" } _LOGGER = logging.getLogger(__name__) ATTRIBUTION = "Weather Data provided by FMI" DEFAULT_NAME = "FMI" FORECAST_OFFSET = [1, 2, 3, 4, 6, 8, 12, 24] # Based on API test runs PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_OFFSET, default=1): vol.In(FORECAST_OFFSET), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=15) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the FMI weather.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) name = config.get(CONF_NAME) time_step = config.get(CONF_OFFSET)
else: _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = 'gismeteo' CONF_CITY = 'city' FORECAST_MODE = ['hourly', 'daily'] URL = "https://services.gismeteo.ru/inform-service/inf_ios/forecast/?city={}&lang=en" MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=300) MMHG2HPA = 1.333223684 DIRECTIONS = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'] ATTR_FORECAST_TEXT_CONDITION = 'text_condition' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_MODE, default='hourly'): vol.In(FORECAST_MODE), vol.Required(CONF_CITY): cv.string, }) def dt_to_utc(dt, offset): local_tz = timezone(timedelta(minutes=offset)) local_dt = datetime.fromisoformat(dt) local_dt_with_tz = local_dt.replace(tzinfo=local_tz) utc_dt = local_dt_with_tz.astimezone(timezone.utc) return utc_dt.isoformat() def _condition(tod, d): if int(d.get('ts')) == 1 and int(d.get('pt')) == 1:
ATTR_WEATHER_PRESSURE, ATTR_WEATHER_TEMPERATURE, ATTR_WEATHER_WIND_BEARING, ATTR_WEATHER_WIND_SPEED, PLATFORM_SCHEMA, WeatherEntity) from homeassistant.const import (CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS) from homeassistant.helpers import config_validation as cv _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_STATION_ID): cv.string, vol.Inclusive(CONF_LATITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.latitude, vol.Inclusive(CONF_LONGITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.longitude, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ZAMG weather platform.""" name = config.get(CONF_NAME) latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) station_id = config.get(CONF_STATION_ID) or closest_station( latitude, longitude, hass.config.config_dir) if station_id not in zamg_stations(hass.config.config_dir):
ATTR_FORECAST_WIND_BEARING, ATTR_CONDITION_CLASS, ATTR_WEATHER_ATTRIBUTION, ATTR_WEATHER_HUMIDITY, ATTR_FORECAST_TIME, PLATFORM_SCHEMA, WeatherEntity, ) from homeassistant.const import CONF_NAME, TEMP_CELSIUS from homeassistant.helpers import config_validation as cv from .sensor import NEACurrentData _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( {vol.Optional(CONF_NAME): cv.string} ) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the NEA weather platform.""" _LOGGER.debug("initialising NEA Weather2 %s", config.get(CONF_NAME)) nea_data = NEACurrentData() try: nea_data.update() except ValueError as err: _LOGGER.error("Received error from NEA Current: %s", err) return False add_entities([NEAWeather(nea_data, config.get(CONF_NAME))], True)
# 雪 'snowy': [400, 401, 402, 403, 405, 406, 407, 408, 409, 410, 499], # 雨夹雪 'snowy-rainy': [404], # 晴 'sunny': [100], # 风 'windy': [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 507, 508], # 'windy-variant': [104], # 其他 'exceptional': [999], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_ID): cv.string, }) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=30) def setup_platform(hass, config, add_entities, discovery_info=None): api_key = config.get(CONF_API_KEY) city_id = config.get(CONF_ID) hew = WeatherData(api_key, city_id) add_entities([HeWeather(hew)], True) class HeWeather(WeatherEntity):
("cloudy", ["Mostly cloudy", "Overcast"]), ("partlycloudy", ["A few clouds", "Partly cloudy"]), ] ) ERRORS = (aiohttp.ClientError, JSONDecodeError) FORECAST_MODE = ["daynight", "hourly"] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Optional(CONF_NAME): cv.string, vol.Inclusive( CONF_LATITUDE, "coordinates", "Latitude and longitude must exist together" ): cv.latitude, vol.Inclusive( CONF_LONGITUDE, "coordinates", "Latitude and longitude must exist together" ): cv.longitude, vol.Optional(CONF_MODE, default="daynight"): vol.In(FORECAST_MODE), vol.Optional(CONF_STATION): cv.string, vol.Required(CONF_API_KEY): cv.string, } ) def convert_condition(time, weather): """ Convert NWS codes to HA condition. Choose first condition in CONDITION_CLASSES that exists in weather code. If no match is found, return first condition from NWS """
from homeassistant.components.weather import PLATFORM_SCHEMA, WeatherEntity from homeassistant.const import (CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS) from homeassistant.helpers import config_validation as cv REQUIREMENTS = ['datapoint==0.4.3'] _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = "Met Office" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Inclusive(CONF_LATITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.latitude, vol.Inclusive(CONF_LONGITUDE, 'coordinates', 'Latitude and longitude must exist together'): cv.longitude, }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Met Office weather platform.""" import datapoint as dp name = config.get(CONF_NAME) datapoint = dp.connection(api_key=config.get(CONF_API_KEY)) latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
DEFAULT_NAME = "AEMET" _LOGGER = logging.getLogger(__name__) FORECAST_MODE = ["hourly", "daily"] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_ELEVATION): cv.small_float, vol.Optional(CONF_MODE, default="daily"): vol.In(FORECAST_MODE), vol.Optional("cache_dir", default=DEFAULT_CACHE_DIR): cv.string, vol.Optional("weather_station"): cv.string, vol.Optional("city"): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional("experimental", default=False): cv.boolean, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the AEMET weather entities.""" _LOGGER.debug("Setting up plataform %s", DEFAULT_NAME)
'lightning': [], 'lightning-rainy': [3, 4, 37, 38, 39, 45, 47], 'partlycloudy': [29, 30, 44], 'pouring': [], 'rainy': [9, 10, 11, 12, 40], 'snowy': [8, 13, 14, 15, 16, 41, 42, 43, 46], 'snowy-rainy': [5, 6, 7, 18], 'sunny': [25, 32, 34, 36], 'windy': [23, 24], 'windy-variant': [], 'exceptional': [0, 1, 2, 19, 22], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_WOEID): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Yahoo! weather platform.""" from yahooweather import get_woeid, UNIT_C, UNIT_F unit = hass.config.units.temperature_unit woeid = config.get(CONF_WOEID) name = config.get(CONF_NAME) yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F # If not exists a customer WOEID/calculation from Home Assistant
from .aemet import AemetData from .const import * _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_ELEVATION): cv.small_float, vol.Optional(CONF_MODE, default=DEFAULT_FORECAST_MODE): vol.In(FORECAST_MODE), vol.Optional(CONF_CACHE_DIR, default=DEFAULT_CACHE_DIR): cv.string, vol.Optional(CONF_SET_WEATHER_STATION): cv.string, vol.Optional(CONF_SET_CITY): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_EXPERIMENTAL, default=False): cv.boolean, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the AEMET weather entities.""" _LOGGER.debug("Setting up plataform %s", DEFAULT_NAME)
import voluptuous as vol from homeassistant.components.weather import WeatherEntity, PLATFORM_SCHEMA from homeassistant.const import ( CONF_NAME, TEMP_CELSIUS, CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE) from homeassistant.helpers import config_validation as cv # Reuse data and API logic from the sensor implementation from homeassistant.components.sensor.metoffice import \ MetOfficeCurrentData, CONF_ATTRIBUTION, CONDITION_CLASSES _LOGGER = logging.getLogger(__name__) REQUIREMENTS = ['datapoint==0.4.3'] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Required(CONF_API_KEY): cv.string, }) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Met Office weather platform.""" import datapoint as dp datapoint = dp.connection(api_key=config.get(CONF_API_KEY)) latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) if None in (latitude, longitude): _LOGGER.error("Latitude or longitude not set in Home Assistant config") return False
from .AemetApi import (AemetApi, ATTR_ELEVATION, ATTR_LAST_UPDATE, ATTR_STATION_NAME, ATTR_WEATHER_PRECIPITATION, ATTR_WEATHER_SNOW, ATTR_WEATHER_WIND_SPEED, ATTR_WEATHER_WIND_BEARING, CONF_ATTRIBUTION, CONF_STATION_ID, CONF_NEIGHBORHOOD_ID, ATTR_FORECAST_TEMP, ATTR_FORECAST_COND, ATTR_FORECAST_PREC, ATTR_FORECAST_PREC_PROB, ATTR_FORECAST_WIND_BEARING, ATTR_FORECAST_WIND_SPEED) DEFAULT_NAME = 'AEMET' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_STATION_ID): cv.string, vol.Required(CONF_NEIGHBORHOOD_ID): cv.string }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the weather platform.""" name = config.get(CONF_NAME) api_key = config.get(CONF_API_KEY) station_id = config.get(CONF_STATION_ID) neighborhood_id = config.get(CONF_NEIGHBORHOOD_ID) aemetApi = AemetApi(api_key=api_key, station_id=station_id,
"rainy": [6, 7, 9, 10, 12, 13, 14, 15], "snowy": [18], "snowy-rainy": [], "sunny": [1], "windy": [], "windy-variant": [], "exceptional": [], } FORECAST_MODE = ["hourly", "daily"] PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_MODE, default="daily"): vol.In(FORECAST_MODE), }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the ipma platform. Deprecated. """ _LOGGER.warning("Loading IPMA via platform config is deprecated")
'lightning': [19], 'lightning-rainy': [20, 23], 'partlycloudy': [2, 3], 'pouring': [8, 11], 'rainy': [6, 7, 9, 10, 12, 13, 14, 15], 'snowy': [18], 'snowy-rainy': [], 'sunny': [1], 'windy': [], 'windy-variant': [], 'exceptional': [], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, }) async def async_setup_platform( hass, config, async_add_entities, discovery_info=None): """Set up the ipma platform. Deprecated. """ _LOGGER.warning("Loading IPMA via platform config is deprecated") latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
"showers": "Ливень", "wet-snow": "Дождь со снегом", "light-snow": "Небольшой снег", "snow": "Снег", "snow-showers": "Снегопад", "hail": "Град", "thunderstorm": "Гроза", "thunderstorm-with-rain": "Дождь с грозой", "thunderstorm-with-hail": "Гроза с градом", } MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=30) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, }) async def async_setup_platform( hass, config, async_add_entities, discovery_info=None): """Set up the Yandex.Weather weather platform.""" longitude = config.get(CONF_LONGITUDE, hass.config.longitude) latitude = config.get(CONF_LATITUDE, hass.config.latitude) name = config.get(CONF_NAME) api_key = config.get(CONF_API_KEY) session = async_get_clientsession(hass) loop = hass.loop async_add_entities([YandexWeather(name, longitude, latitude, api_key, loop, session)], True)
'hurricane': ["飓风", "龙卷风", "热带风暴", "狂暴风", "风暴"], 'rainy': ["毛毛雨", "小雨", "中雨", "大雨", "极端降雨"], 'pouring': ["暴雨", "大暴雨", "特大暴雨", "阵雨", "强阵雨"], #'lightning': ["阵雨", "强阵雨"], 'lightning-rainy': ["雷阵雨", "强雷阵雨"], 'fog': ["雾", "薄雾"], 'hail': ["雷阵雨伴有冰雹"], 'snowy': ["小雪", "中雪", "大雪", "暴雪", "阵雪"], 'snowy-rainy': ["雨夹雪", "雨雪天气", "阵雨夹雪"], } ATTR_UPDATE_TIME = "更新时间" ATTRIBUTION = "来自和风天气的天气数据" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_CITY): cv.string, vol.Required(CONF_APPKEY): cv.string, }) @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the hefeng weather.""" _LOGGER.info("setup platform weather.Heweather...") city = config.get(CONF_CITY) appkey = config.get(CONF_APPKEY) data = WeatherData(hass, city, appkey) yield from data.async_update(dt_util.now()) async_track_time_interval(hass, data.async_update, TIME_BETWEEN_UPDATES)
ATTRIBUTION = "Powered by Dark Sky" ATTR_DAILY_FORECAST_SUMMARY = 'daily_forecast_summary' ATTR_HOURLY_FORECAST_SUMMARY = 'hourly_forecast_summary' CONF_UNITS = 'units' DEFAULT_NAME = 'Dark Sky' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_UNITS): vol.In(['auto', 'si', 'us', 'ca', 'uk', 'uk2']), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=3) def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Dark Sky weather.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) name = config.get(CONF_NAME)
'wind' : 'windy', 'frost' : 'clear-night', 'fog' : 'fog', 'hail' : 'hail', 'dust' : 'exceptional' } def validate_days(days): """Check that days is within bounds.""" if days not in range(1,7): raise vol.error.Invalid("Days is out of Range") return days PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_STATION_ID): cv.string, vol.Optional(CONF_DAYS, default=5): validate_days, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the WillyWeather weather sensor.""" unit = hass.config.units.temperature_unit station_id = config.get(CONF_STATION_ID) api_key = config.get(CONF_API_KEY) days = config.get(CONF_DAYS) name = config.get(CONF_NAME) # If no station_id determine from Home Assistant lat/long if station_id is None: station_id = get_station_id(hass.config.latitude, hass.config.longitude, api_key)
CONF_SERIAL_ENTITY = "serial_sensor" DEFAULT_NAME = "HomeGW Weather Station" ATTR_HOMEGW_DEV = 'dev' ATTR_HOMEGW_TEMPERATURE = 'temp' ATTR_HOMEGW_HUMIDITY = 'hum' ATTR_HOMEGW_PRESSURE = 'pressure' ATTR_HOMEGW_ID = 'id' ATTR_HOMEGW_CHANNEL = 'ch' ATTR_HOMEGW_BATTERY = 'batt' VALUE_HOMEGW_DEV_WEATHER = 'weather' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_SERIAL_ENTITY): cv.entity_id, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) async def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up the homeGW weather.""" name = config.get(CONF_NAME, DEFAULT_NAME) serial_sensor = config.get(CONF_SERIAL_ENTITY) async_add_devices([HomeGWWeather(hass, name, serial_sensor)])
"partly-cloudy-day": "partlycloudy", "partly-cloudy-night": "partlycloudy", "hail": "hail", "thunderstorm": "lightning", "tornado": None, } CONF_UNITS = "units" DEFAULT_NAME = "Dark Sky" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_MODE, default="hourly"): vol.In(FORECAST_MODE), vol.Optional(CONF_UNITS): vol.In(["auto", "si", "us", "ca", "uk", "uk2"]), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, } ) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=3) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dark Sky weather.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) name = config.get(CONF_NAME) mode = config.get(CONF_MODE)
("day", timedelta(hours=12)), ("evening", timedelta(hours=18))) CONF_RATE = "rate" CONF_UPDATE_TIMEOUT = "update_timeout" RATE_INFORMERS = "informers" RATE_FORECAST = "forecast" VALID_RATES = (RATE_INFORMERS, RATE_FORECAST) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_RATE): vol.Any(*VALID_RATES), vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_UPDATE_TIMEOUT): cv.positive_timedelta }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the yandex weather platform.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
'6n': 'lightning', '7': 'freezing', '7n': 'geada', '8': 'snow', '8n': 'snow', '9': 'fog', '9n': 'fog' } CONF_UNITS = 'units' DEFAULT_NAME = 'climatempo' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_CITY): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Climatmepo weather.""" name = config.get(CONF_NAME) units = 'si' climatempo = ClimatempoData( config.get(CONF_API_KEY), config.get(CONF_CITY) ) add_entities([ClimatempoWeather(name, climatempo)], True)
from .const import CONF_TRACK_HOME _LOGGER = logging.getLogger(__name__) ATTRIBUTION = ("Weather forecast from met.no, delivered by the Norwegian " "Meteorological Institute.") DEFAULT_NAME = "Met.no" URL = "https://aa015h6buqvih86i1.api.met.no/weatherapi/locationforecast/1.9/" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Inclusive(CONF_LATITUDE, "coordinates", "Latitude and longitude must exist together"): cv.latitude, vol.Inclusive(CONF_LONGITUDE, "coordinates", "Latitude and longitude must exist together"): cv.longitude, vol.Optional(CONF_ELEVATION): int, }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Met.no weather platform.""" _LOGGER.warning("Loading Met.no via platform config is deprecated") # Add defaults. config = {CONF_ELEVATION: hass.config.elevation, **config}
ATTRIBUTION = "来自和风天气的天气数据" Weather_entities = {} PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_NAME): cv.string, vol.Optional(CONF_DEVICE_TRACKER_ENTITY, default=''): cv.string, vol.Required(CONF_LOCATION): cv.string, vol.Optional(CONF_HEFENG_APPKEY, default=''): cv.string, vol.Required(CONF_HEFENG_FREE_APPKEY): cv.string, vol.Required(CONF_CAIYUN_APPKEY): cv.string, vol.Optional(CONF_HEFENG_NOW_IS_FREE, default=True): cv.boolean, vol.Optional(CONF_HEFENG_DAILY_IS_FREE, default=True): cv.boolean, vol.Optional(CONF_HEFENG_HOURLY_IS_FREE, default=True): cv.boolean, vol.Optional(CONF_HEFENG_AIR_IS_FREE, default=True): cv.boolean, vol.Optional(CONF_HEFENG_LIFESTYLE_IS_FREE, default=True): cv.boolean, }) @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
'cloudy': 'cloudy', 'partly-cloudy-day': 'partlycloudy', 'partly-cloudy-night': 'partlycloudy', 'hail': 'hail', 'thunderstorm': 'lightning', 'tornado': None, } CONF_UNITS = 'units' DEFAULT_NAME = 'Dark Sky' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_MODE, default='hourly'): vol.In(FORECAST_MODE), vol.Optional(CONF_UNITS): vol.In(['auto', 'si', 'us', 'ca', 'uk', 'uk2']), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=3) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Dark Sky weather.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) name = config.get(CONF_NAME) mode = config.get(CONF_MODE) units = config.get(CONF_UNITS)
import logging import voluptuous as vol # Reuse data and API logic from the sensor implementation from homeassistant.components.sensor.bom import ( CONF_STATION, BOMCurrentData, closest_station, validate_station) from homeassistant.components.weather import PLATFORM_SCHEMA, WeatherEntity from homeassistant.const import ( CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS) from homeassistant.helpers import config_validation as cv _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_STATION): validate_station, }) 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()
import homeassistant.helpers.config_validation as cv from .cache import Cache REQUIREMENTS = ['pyowm==2.10.0'] _LOGGER = logging.getLogger(__name__) FORECAST_MODE = ['hourly', 'daily', 'freedaily'] DEFAULT_NAME = 'CustomOpenWeatherMap' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_MODE, default='hourly'): vol.In(FORECAST_MODE), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the OpenWeatherMap weather platform.""" longitude = config.get(CONF_LONGITUDE, round(hass.config.longitude, 5)) latitude = config.get(CONF_LATITUDE, round(hass.config.latitude, 5)) name = config.get(CONF_NAME) mode = config.get(CONF_MODE) Cache.set_cache_path(hass.config.path("")) owm = OwmClientWrapper(config.get(CONF_API_KEY))
'humidity': ['Humidity', '%'], 'pressure': ['Pressure', 'hPa'], 'clouds': ['Cloud coverage', '%'], 'rain': ['Rain', 'mm'], 'snow': ['Snow', 'mm'], 'storm': ['Storm', None], 'geomagnetic': ['Geomagnetic field', ''], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_API_KEY): cv.string, vol.Optional(CONF_MONITORED_CONDITIONS, default=[]): vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]), vol.Optional(CONF_FORECAST, default=False): cv.boolean, vol.Optional(CONF_CACHE_DIR, default=DEFAULT_CACHE_DIR): cv.string, vol.Optional(CONF_LANGUAGE): cv.string, }) def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Gismeteo weather platform.""" _LOGGER.debug('Version %s', VERSION) _LOGGER.info('if you have ANY issues with this, please report them here:' ' https://github.com/Limych/HomeAssistantComponents') if None in (hass.config.latitude, hass.config.longitude):
'lightning': ['g'], 'lightning-rainy': ['s'], 'partlycloudy': ['b', 'j', 'o', 'r'], 'pouring': ['l', 'q'], 'rainy': ['f', 'h', 'k', 'm'], 'snowy': ['u', 'i', 'v', 't'], 'snowy-rainy': ['w'], 'sunny': ['a'], 'windy': [], 'windy-variant': [], 'exceptional': [], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, vol.Optional(CONF_LATITUDE): cv.latitude, vol.Optional(CONF_LONGITUDE): cv.longitude, vol.Optional(CONF_FORECAST, default=True): cv.boolean, }) async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the buienradar platform.""" latitude = config.get(CONF_LATITUDE, hass.config.latitude) longitude = config.get(CONF_LONGITUDE, hass.config.longitude) if None in (latitude, longitude): _LOGGER.error("Latitude or longitude not set in Home Assistant config") return False coordinates = {CONF_LATITUDE: float(latitude),
'lightning': [37], 'lightning-rainy': [38, 39], 'partlycloudy': [44], 'pouring': [40, 45], 'rainy': [9, 11, 12], 'snowy': [8, 13, 14, 15, 16, 41, 42, 43], 'snowy-rainy': [5, 6, 7, 10, 46, 47], 'sunny': [32], 'windy': [24], 'windy-variant': [], 'exceptional': [0, 1, 2, 3, 4, 25, 36], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_WOEID, default=None): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_FORECAST, default=0): vol.All(vol.Coerce(int), vol.Range(min=0, max=5)), }) def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Yahoo! weather platform.""" from yahooweather import get_woeid, UNIT_C, UNIT_F unit = hass.config.units.temperature_unit woeid = config.get(CONF_WOEID) forecast = config.get(CONF_FORECAST) name = config.get(CONF_NAME) yunit = UNIT_C if unit == TEMP_CELSIUS else UNIT_F