Remove invalid return values in setup methods [i-p] (#63363)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
2709db008c
commit
5140c1fa6a
21 changed files with 237 additions and 56 deletions
|
@ -1,4 +1,6 @@
|
||||||
"""Email sensor support."""
|
"""Email sensor support."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
import datetime
|
import datetime
|
||||||
import email
|
import email
|
||||||
|
@ -17,7 +19,10 @@ from homeassistant.const import (
|
||||||
CONF_VALUE_TEMPLATE,
|
CONF_VALUE_TEMPLATE,
|
||||||
CONTENT_TYPE_TEXT_PLAIN,
|
CONTENT_TYPE_TEXT_PLAIN,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -45,7 +50,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Email sensor platform."""
|
"""Set up the Email sensor platform."""
|
||||||
reader = EmailReader(
|
reader = EmailReader(
|
||||||
config.get(CONF_USERNAME),
|
config.get(CONF_USERNAME),
|
||||||
|
@ -67,8 +77,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
|
||||||
if sensor.connected:
|
if sensor.connected:
|
||||||
add_entities([sensor], True)
|
add_entities([sensor], True)
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class EmailReader:
|
class EmailReader:
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
"""Support for Keene Electronics IR-IP devices."""
|
"""Support for Keene Electronics IR-IP devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools as ft
|
import functools as ft
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components import remote
|
from homeassistant.components import remote
|
||||||
from homeassistant.const import CONF_DEVICE, CONF_NAME
|
from homeassistant.const import CONF_DEVICE, CONF_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import CONF_REMOTE, DOMAIN
|
from . import CONF_REMOTE, DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Kira platform."""
|
"""Set up the Kira platform."""
|
||||||
if discovery_info:
|
if discovery_info:
|
||||||
name = discovery_info.get(CONF_NAME)
|
name = discovery_info.get(CONF_NAME)
|
||||||
|
@ -19,7 +29,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
|
||||||
kira = hass.data[DOMAIN][CONF_REMOTE][name]
|
kira = hass.data[DOMAIN][CONF_REMOTE][name]
|
||||||
add_entities([KiraRemote(device, kira)])
|
add_entities([KiraRemote(device, kira)])
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class KiraRemote(Entity):
|
class KiraRemote(Entity):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for KWB Easyfire."""
|
"""Support for KWB Easyfire."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from pykwb import kwb
|
from pykwb import kwb
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -11,7 +13,10 @@ from homeassistant.const import (
|
||||||
CONF_TYPE,
|
CONF_TYPE,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
DEFAULT_RAW = False
|
DEFAULT_RAW = False
|
||||||
DEFAULT_NAME = "KWB"
|
DEFAULT_NAME = "KWB"
|
||||||
|
@ -43,7 +48,12 @@ ETHERNET_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
PLATFORM_SCHEMA = vol.Schema(vol.Any(SERIAL_SCHEMA, ETHERNET_SCHEMA))
|
PLATFORM_SCHEMA = vol.Schema(vol.Any(SERIAL_SCHEMA, ETHERNET_SCHEMA))
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the KWB component."""
|
"""Set up the KWB component."""
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
port = config.get(CONF_PORT)
|
port = config.get(CONF_PORT)
|
||||||
|
@ -57,7 +67,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
elif connection_type == "tcp":
|
elif connection_type == "tcp":
|
||||||
easyfire = kwb.KWBEasyfire(MODE_TCP, host, port)
|
easyfire = kwb.KWBEasyfire(MODE_TCP, host, port)
|
||||||
else:
|
else:
|
||||||
return False
|
return
|
||||||
|
|
||||||
easyfire.run_thread()
|
easyfire.run_thread()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for LIFX lights."""
|
"""Support for LIFX lights."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -35,6 +37,7 @@ from homeassistant.components.light import (
|
||||||
LightEntity,
|
LightEntity,
|
||||||
preprocess_turn_on_alternatives,
|
preprocess_turn_on_alternatives,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
ATTR_MODE,
|
ATTR_MODE,
|
||||||
|
@ -42,12 +45,14 @@ from homeassistant.const import (
|
||||||
ATTR_SW_VERSION,
|
ATTR_SW_VERSION,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
)
|
)
|
||||||
from homeassistant.core import ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.helpers.device_registry as dr
|
import homeassistant.helpers.device_registry as dr
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
|
@ -168,12 +173,21 @@ def aiolifx_effects():
|
||||||
return aiolifx_effects_module
|
return aiolifx_effects_module
|
||||||
|
|
||||||
|
|
||||||
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 LIFX light platform. Obsolete."""
|
"""Set up the LIFX light platform. Obsolete."""
|
||||||
_LOGGER.warning("LIFX no longer works with light platform configuration")
|
_LOGGER.warning("LIFX no longer works with light platform configuration")
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
"""Set up LIFX from a config entry."""
|
"""Set up LIFX from a config entry."""
|
||||||
# Priority 1: manual config
|
# Priority 1: manual config
|
||||||
if not (interfaces := hass.data[LIFX_DOMAIN].get(DOMAIN)):
|
if not (interfaces := hass.data[LIFX_DOMAIN].get(DOMAIN)):
|
||||||
|
@ -191,8 +205,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
for interface in interfaces:
|
for interface in interfaces:
|
||||||
lifx_manager.start_discovery(interface)
|
lifx_manager.start_discovery(interface)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def lifx_features(bulb):
|
def lifx_features(bulb):
|
||||||
"""Return a feature map for this bulb, or a default map if unknown."""
|
"""Return a feature map for this bulb, or a default map if unknown."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for LIFX Cloud scenes."""
|
"""Support for LIFX Cloud scenes."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
@ -11,8 +13,11 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.scene import Scene
|
from homeassistant.components.scene import Scene
|
||||||
from homeassistant.const import CONF_PLATFORM, CONF_TIMEOUT, CONF_TOKEN
|
from homeassistant.const import CONF_PLATFORM, CONF_TIMEOUT, CONF_TOKEN
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_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."""
|
"""Set up the scenes stored in the LIFX Cloud."""
|
||||||
token = config.get(CONF_TOKEN)
|
token = config.get(CONF_TOKEN)
|
||||||
timeout = config.get(CONF_TIMEOUT)
|
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):
|
except (asyncio.TimeoutError, aiohttp.ClientError):
|
||||||
_LOGGER.exception("Error on %s", url)
|
_LOGGER.exception("Error on %s", url)
|
||||||
return False
|
return
|
||||||
|
|
||||||
status = scenes_resp.status
|
status = scenes_resp.status
|
||||||
if status == HTTPStatus.OK:
|
if status == HTTPStatus.OK:
|
||||||
data = await scenes_resp.json()
|
data = await scenes_resp.json()
|
||||||
devices = [LifxCloudScene(hass, headers, timeout, scene) for scene in data]
|
devices = [LifxCloudScene(hass, headers, timeout, scene) for scene in data]
|
||||||
async_add_entities(devices)
|
async_add_entities(devices)
|
||||||
return True
|
return
|
||||||
if status == HTTPStatus.UNAUTHORIZED:
|
if status == HTTPStatus.UNAUTHORIZED:
|
||||||
_LOGGER.error("Unauthorized (bad token?) on %s", url)
|
_LOGGER.error("Unauthorized (bad token?) on %s", url)
|
||||||
return False
|
return
|
||||||
|
|
||||||
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
|
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class LifxCloudScene(Scene):
|
class LifxCloudScene(Scene):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Details about the built-in battery."""
|
"""Details about the built-in battery."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -11,7 +13,10 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_NAME, CONF_NAME, PERCENTAGE
|
from homeassistant.const import ATTR_NAME, CONF_NAME, PERCENTAGE
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -53,7 +58,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Linux Battery sensor."""
|
"""Set up the Linux Battery sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
battery_id = config.get(CONF_BATTERY)
|
battery_id = config.get(CONF_BATTERY)
|
||||||
|
@ -66,7 +76,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
os.listdir(os.path.join(DEFAULT_PATH, f"BAT{battery_id}"))
|
os.listdir(os.path.join(DEFAULT_PATH, f"BAT{battery_id}"))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
_LOGGER.error("No battery found")
|
_LOGGER.error("No battery found")
|
||||||
return False
|
return
|
||||||
|
|
||||||
add_entities([LinuxBatterySensor(name, battery_id, system)], True)
|
add_entities([LinuxBatterySensor(name, battery_id, system)], True)
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
"""Support for the Locative platform."""
|
"""Support for the Locative platform."""
|
||||||
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS
|
from homeassistant.components.device_tracker import SOURCE_TYPE_GPS
|
||||||
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
from homeassistant.components.device_tracker.config_entry import TrackerEntity
|
||||||
from homeassistant.core import callback
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import DOMAIN as LT_DOMAIN, TRACKER_UPDATE
|
from . import DOMAIN as LT_DOMAIN, TRACKER_UPDATE
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
) -> None:
|
||||||
"""Configure a dispatcher connection based on a config entry."""
|
"""Configure a dispatcher connection based on a config entry."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -24,8 +28,6 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
entry.entry_id
|
entry.entry_id
|
||||||
] = async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
] = async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class LocativeEntity(TrackerEntity):
|
class LocativeEntity(TrackerEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Lutron shades."""
|
"""Support for Lutron shades."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
|
@ -8,13 +10,21 @@ from homeassistant.components.cover import (
|
||||||
SUPPORT_SET_POSITION,
|
SUPPORT_SET_POSITION,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
|
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Lutron shades."""
|
"""Set up the Lutron shades."""
|
||||||
devs = []
|
devs = []
|
||||||
for (area_name, device) in hass.data[LUTRON_DEVICES]["cover"]:
|
for (area_name, device) in hass.data[LUTRON_DEVICES]["cover"]:
|
||||||
|
@ -22,7 +32,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
devs.append(dev)
|
devs.append(dev)
|
||||||
|
|
||||||
add_entities(devs, True)
|
add_entities(devs, True)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class LutronCover(LutronDevice, CoverEntity):
|
class LutronCover(LutronDevice, CoverEntity):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Ubiquiti mFi sensors."""
|
"""Support for Ubiquiti mFi sensors."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mficlient.client import FailedToLogin, MFiClient
|
from mficlient.client import FailedToLogin, MFiClient
|
||||||
|
@ -21,7 +23,10 @@ from homeassistant.const import (
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -51,7 +56,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up mFi sensors."""
|
"""Set up mFi sensors."""
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
|
@ -67,7 +77,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
)
|
)
|
||||||
except (FailedToLogin, requests.exceptions.ConnectionError) as ex:
|
except (FailedToLogin, requests.exceptions.ConnectionError) as ex:
|
||||||
_LOGGER.error("Unable to connect to mFi: %s", str(ex))
|
_LOGGER.error("Unable to connect to mFi: %s", str(ex))
|
||||||
return False
|
return
|
||||||
|
|
||||||
add_entities(
|
add_entities(
|
||||||
MfiSensor(port, hass)
|
MfiSensor(port, hass)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Ubiquiti mFi switches."""
|
"""Support for Ubiquiti mFi switches."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from mficlient.client import FailedToLogin, MFiClient
|
from mficlient.client import FailedToLogin, MFiClient
|
||||||
|
@ -14,7 +16,10 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_VERIFY_SSL,
|
CONF_VERIFY_SSL,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -35,7 +40,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up mFi sensors."""
|
"""Set up mFi sensors."""
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
|
@ -51,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
)
|
)
|
||||||
except (FailedToLogin, requests.exceptions.ConnectionError) as ex:
|
except (FailedToLogin, requests.exceptions.ConnectionError) as ex:
|
||||||
_LOGGER.error("Unable to connect to mFi: %s", str(ex))
|
_LOGGER.error("Unable to connect to mFi: %s", str(ex))
|
||||||
return False
|
return
|
||||||
|
|
||||||
add_entities(
|
add_entities(
|
||||||
MfiSwitch(port)
|
MfiSwitch(port)
|
||||||
|
|
|
@ -20,7 +20,10 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -60,7 +63,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the available CO2 sensors."""
|
"""Set up the available CO2 sensors."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -71,7 +79,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
config.get(CONF_SERIAL_DEVICE),
|
config.get(CONF_SERIAL_DEVICE),
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
return False
|
return
|
||||||
|
|
||||||
data = MHZClient(co2sensor, config.get(CONF_SERIAL_DEVICE))
|
data = MHZClient(co2sensor, config.get(CONF_SERIAL_DEVICE))
|
||||||
name = config[CONF_NAME]
|
name = config[CONF_NAME]
|
||||||
|
|
|
@ -1,20 +1,27 @@
|
||||||
"""Support for the myStrom buttons."""
|
"""Support for the myStrom buttons."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorEntity
|
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorEntity
|
||||||
from homeassistant.components.http import HomeAssistantView
|
from homeassistant.components.http import HomeAssistantView
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
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 myStrom Binary Sensor."""
|
"""Set up myStrom Binary Sensor."""
|
||||||
hass.http.register_view(MyStromView(async_add_entities))
|
hass.http.register_view(MyStromView(async_add_entities))
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class MyStromView(HomeAssistantView):
|
class MyStromView(HomeAssistantView):
|
||||||
"""View to handle requests from myStrom buttons."""
|
"""View to handle requests from myStrom buttons."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""OpenEnergyMonitor Thermostat Support."""
|
"""OpenEnergyMonitor Thermostat Support."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from oemthermostat import Thermostat
|
from oemthermostat import Thermostat
|
||||||
import requests
|
import requests
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -22,7 +24,10 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
|
@ -38,7 +43,12 @@ SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE
|
||||||
SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the oemthermostat platform."""
|
"""Set up the oemthermostat platform."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
|
@ -49,7 +59,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
try:
|
try:
|
||||||
therm = Thermostat(host, port=port, username=username, password=password)
|
therm = Thermostat(host, port=port, username=username, password=password)
|
||||||
except (ValueError, AssertionError, requests.RequestException):
|
except (ValueError, AssertionError, requests.RequestException):
|
||||||
return False
|
return
|
||||||
|
|
||||||
add_entities((ThermostatDevice(therm, name),), True)
|
add_entities((ThermostatDevice(therm, name),), True)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for openexchangerates.org exchange rates service."""
|
"""Support for openexchangerates.org exchange rates service."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
|
@ -14,7 +16,10 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_QUOTE,
|
CONF_QUOTE,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -37,7 +42,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Open Exchange Rates sensor."""
|
"""Set up the Open Exchange Rates sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
api_key = config.get(CONF_API_KEY)
|
api_key = config.get(CONF_API_KEY)
|
||||||
|
@ -51,7 +61,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
|
||||||
if response.status_code != HTTPStatus.OK:
|
if response.status_code != HTTPStatus.OK:
|
||||||
_LOGGER.error("Check your OpenExchangeRates API key")
|
_LOGGER.error("Check your OpenExchangeRates API key")
|
||||||
return False
|
return
|
||||||
|
|
||||||
rest.update()
|
rest.update()
|
||||||
add_entities([OpenexchangeratesSensor(rest, name, quote)], True)
|
add_entities([OpenexchangeratesSensor(rest, name, quote)], True)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Openhome Devices."""
|
"""Support for Openhome Devices."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
|
@ -25,7 +27,10 @@ from homeassistant.components.media_player.const import (
|
||||||
SUPPORT_VOLUME_STEP,
|
SUPPORT_VOLUME_STEP,
|
||||||
)
|
)
|
||||||
from homeassistant.const import STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING
|
from homeassistant.const import STATE_IDLE, STATE_OFF, STATE_PAUSED, STATE_PLAYING
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .const import ATTR_PIN_INDEX, DATA_OPENHOME, SERVICE_INVOKE_PIN
|
from .const import ATTR_PIN_INDEX, DATA_OPENHOME, SERVICE_INVOKE_PIN
|
||||||
|
|
||||||
|
@ -34,7 +39,12 @@ SUPPORT_OPENHOME = SUPPORT_SELECT_SOURCE | SUPPORT_TURN_OFF | SUPPORT_TURN_ON
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
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 Openhome platform."""
|
"""Set up the Openhome platform."""
|
||||||
|
|
||||||
if not discovery_info:
|
if not discovery_info:
|
||||||
|
@ -51,7 +61,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
# if device has already been discovered
|
# if device has already been discovered
|
||||||
if device.uuid() in openhome_data:
|
if device.uuid() in openhome_data:
|
||||||
return True
|
return
|
||||||
|
|
||||||
entity = OpenhomeDevice(hass, device)
|
entity = OpenhomeDevice(hass, device)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for One-Time Password (OTP)."""
|
"""Support for One-Time Password (OTP)."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pyotp
|
import pyotp
|
||||||
|
@ -6,8 +8,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_NAME, CONF_TOKEN
|
from homeassistant.const import CONF_NAME, CONF_TOKEN
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
DEFAULT_NAME = "OTP Sensor"
|
DEFAULT_NAME = "OTP Sensor"
|
||||||
|
|
||||||
|
@ -23,13 +27,17 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 OTP sensor."""
|
"""Set up the OTP sensor."""
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
token = config.get(CONF_TOKEN)
|
token = config.get(CONF_TOKEN)
|
||||||
|
|
||||||
async_add_entities([TOTPSensor(name, token)], True)
|
async_add_entities([TOTPSensor(name, token)], True)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
# Only TOTP supported at the moment, HOTP might be added later
|
# Only TOTP supported at the moment, HOTP might be added later
|
||||||
|
|
|
@ -5,21 +5,25 @@ from homeassistant.components.device_tracker.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
SOURCE_TYPE_GPS,
|
SOURCE_TYPE_GPS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
ATTR_GPS_ACCURACY,
|
ATTR_GPS_ACCURACY,
|
||||||
ATTR_LATITUDE,
|
ATTR_LATITUDE,
|
||||||
ATTR_LONGITUDE,
|
ATTR_LONGITUDE,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
|
||||||
from . import DOMAIN as OT_DOMAIN
|
from . import DOMAIN as OT_DOMAIN
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry, async_add_entities):
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
) -> None:
|
||||||
"""Set up OwnTracks based off an entry."""
|
"""Set up OwnTracks based off an entry."""
|
||||||
# Restore previously loaded devices
|
# Restore previously loaded devices
|
||||||
dev_reg = await device_registry.async_get_registry(hass)
|
dev_reg = await device_registry.async_get_registry(hass)
|
||||||
|
@ -52,8 +56,6 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
||||||
if entities:
|
if entities:
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class OwnTracksEntity(TrackerEntity, RestoreEntity):
|
class OwnTracksEntity(TrackerEntity, RestoreEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Component for controlling Pandora stations through the pianobar client."""
|
"""Component for controlling Pandora stations through the pianobar client."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -31,6 +33,9 @@ from homeassistant.const import (
|
||||||
STATE_PAUSED,
|
STATE_PAUSED,
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -57,10 +62,15 @@ CURRENT_SONG_PATTERN = re.compile(r'"(.*?)"\s+by\s+"(.*?)"\son\s+"(.*?)"', re.MU
|
||||||
STATION_PATTERN = re.compile(r'Station\s"(.+?)"', re.MULTILINE)
|
STATION_PATTERN = re.compile(r'Station\s"(.+?)"', re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Pandora media player platform."""
|
"""Set up the Pandora media player platform."""
|
||||||
if not _pianobar_exists():
|
if not _pianobar_exists():
|
||||||
return False
|
return
|
||||||
pandora = PandoraMediaPlayer("Pandora")
|
pandora = PandoraMediaPlayer("Pandora")
|
||||||
|
|
||||||
# Make sure we end the pandora subprocess on exit in case user doesn't
|
# Make sure we end the pandora subprocess on exit in case user doesn't
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Piglow LED's."""
|
"""Support for Piglow LED's."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -14,7 +16,10 @@ from homeassistant.components.light import (
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -28,11 +33,16 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Piglow Light platform."""
|
"""Set up the Piglow Light platform."""
|
||||||
if subprocess.getoutput("i2cdetect -q -y 1 | grep -o 54") != "54":
|
if subprocess.getoutput("i2cdetect -q -y 1 | grep -o 54") != "54":
|
||||||
_LOGGER.error("A Piglow device was not found")
|
_LOGGER.error("A Piglow device was not found")
|
||||||
return False
|
return
|
||||||
|
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Pocket Casts."""
|
"""Support for Pocket Casts."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -7,7 +9,10 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -22,7 +27,12 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the pocketcasts platform for sensors."""
|
"""Set up the pocketcasts platform for sensors."""
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
|
@ -33,7 +43,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
add_entities([PocketCastsSensor(api)], True)
|
add_entities([PocketCastsSensor(api)], True)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
_LOGGER.error("Connection to server failed: %s", err)
|
_LOGGER.error("Connection to server failed: %s", err)
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class PocketCastsSensor(SensorEntity):
|
class PocketCastsSensor(SensorEntity):
|
||||||
|
|
|
@ -13,7 +13,10 @@ from homeassistant.components.sensor import (
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_MONITORED_CONDITIONS
|
from homeassistant.const import CONF_API_KEY, CONF_MONITORED_CONDITIONS
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -72,14 +75,19 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config: ConfigType,
|
||||||
|
add_entities: AddEntitiesCallback,
|
||||||
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
) -> None:
|
||||||
"""Set up the Pushbullet Sensor platform."""
|
"""Set up the Pushbullet Sensor platform."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pushbullet = PushBullet(config.get(CONF_API_KEY))
|
pushbullet = PushBullet(config.get(CONF_API_KEY))
|
||||||
except InvalidKeyError:
|
except InvalidKeyError:
|
||||||
_LOGGER.error("Wrong API key for Pushbullet supplied")
|
_LOGGER.error("Wrong API key for Pushbullet supplied")
|
||||||
return False
|
return
|
||||||
|
|
||||||
pbprovider = PushBulletNotificationProvider(pushbullet)
|
pbprovider = PushBulletNotificationProvider(pushbullet)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue