Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -4,8 +4,7 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.air_quality import (
|
||||
PLATFORM_SCHEMA, AirQualityEntity)
|
||||
from homeassistant.components.air_quality import PLATFORM_SCHEMA, AirQualityEntity
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -14,20 +13,18 @@ from homeassistant.util import Throttle
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ATTRIBUTION = 'Data provided by openSenseMap'
|
||||
ATTRIBUTION = "Data provided by openSenseMap"
|
||||
|
||||
CONF_STATION_ID = 'station_id'
|
||||
CONF_STATION_ID = "station_id"
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=10)
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_STATION_ID): cv.string,
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
})
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{vol.Required(CONF_STATION_ID): cv.string, vol.Optional(CONF_NAME): cv.string}
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the openSenseMap air quality platform."""
|
||||
from opensensemap_api import OpenSenseMap
|
||||
|
||||
|
@ -39,11 +36,11 @@ async def async_setup_platform(
|
|||
|
||||
await osm_api.async_update()
|
||||
|
||||
if 'name' not in osm_api.api.data:
|
||||
if "name" not in osm_api.api.data:
|
||||
_LOGGER.error("Station %s is not available", station_id)
|
||||
raise PlatformNotReady
|
||||
|
||||
station_name = osm_api.api.data['name'] if name is None else name
|
||||
station_name = osm_api.api.data["name"] if name is None else name
|
||||
|
||||
async_add_entities([OpenSenseMapQuality(station_name, osm_api)], True)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue