Remove invalid return values in setup methods [i-p] (#63363)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-01-04 11:30:13 +01:00 committed by GitHub
parent 2709db008c
commit 5140c1fa6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 237 additions and 56 deletions

View file

@ -1,4 +1,6 @@
"""Support for LIFX Cloud scenes."""
from __future__ import annotations
import asyncio
from http import HTTPStatus
import logging
@ -11,8 +13,11 @@ import voluptuous as vol
from homeassistant.components.scene import Scene
from homeassistant.const import CONF_PLATFORM, CONF_TIMEOUT, CONF_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
_LOGGER = logging.getLogger(__name__)
@ -27,7 +32,12 @@ PLATFORM_SCHEMA = vol.Schema(
)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the scenes stored in the LIFX Cloud."""
token = config.get(CONF_TOKEN)
timeout = config.get(CONF_TIMEOUT)
@ -43,20 +53,19 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
except (asyncio.TimeoutError, aiohttp.ClientError):
_LOGGER.exception("Error on %s", url)
return False
return
status = scenes_resp.status
if status == HTTPStatus.OK:
data = await scenes_resp.json()
devices = [LifxCloudScene(hass, headers, timeout, scene) for scene in data]
async_add_entities(devices)
return True
return
if status == HTTPStatus.UNAUTHORIZED:
_LOGGER.error("Unauthorized (bad token?) on %s", url)
return False
return
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
return False
class LifxCloudScene(Scene):