Check discovery_info is available and add setup type hints (#63782)
* Add setup type hints to ebusd
* Add setup type hints to envisalink
* Add setup type hints to sisyphus
* Add setup type hints to iperf3
* Add setup type hints to greeneye_monitor
* Revert "Add setup type hints to iperf3"
This reverts commit 9a382e4ba3
.
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
423674c0c9
commit
183a739968
7 changed files with 85 additions and 15 deletions
|
@ -1,8 +1,13 @@
|
|||
"""Support for Ebusd sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import Throttle
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
@ -19,8 +24,15 @@ MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=15)
|
|||
_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 Ebus sensor."""
|
||||
if not discovery_info:
|
||||
return
|
||||
ebusd_api = hass.data[DOMAIN]
|
||||
monitored_conditions = discovery_info["monitored_conditions"]
|
||||
name = discovery_info["client_name"]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for Envisalink-based alarm control panels (Honeywell/DSC)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
@ -24,9 +26,11 @@ from homeassistant.const import (
|
|||
STATE_ALARM_TRIGGERED,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import ServiceCall, callback
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import (
|
||||
CONF_PANIC,
|
||||
|
@ -51,8 +55,15 @@ ALARM_KEYPRESS_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:
|
||||
"""Perform the setup for Envisalink alarm panels."""
|
||||
if not discovery_info:
|
||||
return
|
||||
configured_partitions = discovery_info["partitions"]
|
||||
code = discovery_info[CONF_CODE]
|
||||
panic_type = discovery_info[CONF_PANIC]
|
||||
|
@ -93,8 +104,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
schema=ALARM_KEYPRESS_SCHEMA,
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
|
||||
"""Representation of an Envisalink-based alarm panel."""
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
"""Support for Envisalink zone states- represented as binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.const import ATTR_LAST_TRIP_TIME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import (
|
||||
|
@ -20,8 +24,15 @@ from . import (
|
|||
_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 Envisalink binary sensor devices."""
|
||||
if not discovery_info:
|
||||
return
|
||||
configured_zones = discovery_info["zones"]
|
||||
|
||||
devices = []
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
"""Support for Envisalink sensors (shows panel info)."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import (
|
||||
CONF_PARTITIONNAME,
|
||||
|
@ -17,8 +21,15 @@ from . import (
|
|||
_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:
|
||||
"""Perform the setup for Envisalink sensor devices."""
|
||||
if not discovery_info:
|
||||
return
|
||||
configured_partitions = discovery_info["partitions"]
|
||||
|
||||
devices = []
|
||||
|
|
|
@ -16,9 +16,9 @@ from homeassistant.const import (
|
|||
TIME_MINUTES,
|
||||
TIME_SECONDS,
|
||||
)
|
||||
from homeassistant.core import Config, HomeAssistant
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from .const import (
|
||||
CONF_CHANNELS,
|
||||
|
@ -45,11 +45,14 @@ COUNTER_ICON = "mdi:counter"
|
|||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: Config,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up a single GEM temperature sensor."""
|
||||
if not discovery_info:
|
||||
return
|
||||
|
||||
entities: list[GEMSensor] = []
|
||||
for monitor_config in discovery_info[CONF_MONITORS]:
|
||||
monitor_serial_number = monitor_config[CONF_SERIAL_NUMBER]
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
"""Support for the light on the Sisyphus Kinetic Art Table."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import aiohttp
|
||||
|
||||
from homeassistant.components.light import SUPPORT_BRIGHTNESS, LightEntity
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import DATA_SISYPHUS
|
||||
|
||||
|
@ -14,8 +19,15 @@ _LOGGER = logging.getLogger(__name__)
|
|||
SUPPORTED_FEATURES = SUPPORT_BRIGHTNESS
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up a single Sisyphus table."""
|
||||
if not discovery_info:
|
||||
return
|
||||
host = discovery_info[CONF_HOST]
|
||||
try:
|
||||
table_holder = hass.data[DATA_SISYPHUS][host]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for track controls on the Sisyphus Kinetic Art Table."""
|
||||
from __future__ import annotations
|
||||
|
||||
import aiohttp
|
||||
from sisyphus_control import Track
|
||||
|
||||
|
@ -21,7 +23,10 @@ from homeassistant.const import (
|
|||
STATE_PAUSED,
|
||||
STATE_PLAYING,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from . import DATA_SISYPHUS
|
||||
|
||||
|
@ -40,8 +45,15 @@ SUPPORTED_FEATURES = (
|
|||
)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up a media player entity for a Sisyphus table."""
|
||||
if not discovery_info:
|
||||
return
|
||||
host = discovery_info[CONF_HOST]
|
||||
try:
|
||||
table_holder = hass.data[DATA_SISYPHUS][host]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue