Add setup type hints to envisalink

This commit is contained in:
epenet
2022-01-10 08:13:58 +00:00
parent a630372912
commit 27073abc62
3 changed files with 39 additions and 8 deletions

View File

@@ -1,4 +1,6 @@
"""Support for Envisalink-based alarm control panels (Honeywell/DSC).""" """Support for Envisalink-based alarm control panels (Honeywell/DSC)."""
from __future__ import annotations
import logging import logging
import voluptuous as vol import voluptuous as vol
@@ -24,9 +26,11 @@ from homeassistant.const import (
STATE_ALARM_TRIGGERED, STATE_ALARM_TRIGGERED,
STATE_UNKNOWN, STATE_UNKNOWN,
) )
from homeassistant.core import ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ( from . import (
CONF_PANIC, 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.""" """Perform the setup for Envisalink alarm panels."""
if not discovery_info:
return
configured_partitions = discovery_info["partitions"] configured_partitions = discovery_info["partitions"]
code = discovery_info[CONF_CODE] code = discovery_info[CONF_CODE]
panic_type = discovery_info[CONF_PANIC] 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, schema=ALARM_KEYPRESS_SCHEMA,
) )
return True
class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity): class EnvisalinkAlarm(EnvisalinkDevice, AlarmControlPanelEntity):
"""Representation of an Envisalink-based alarm panel.""" """Representation of an Envisalink-based alarm panel."""

View File

@@ -1,11 +1,15 @@
"""Support for Envisalink zone states- represented as binary sensors.""" """Support for Envisalink zone states- represented as binary sensors."""
from __future__ import annotations
import datetime import datetime
import logging import logging
from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.const import ATTR_LAST_TRIP_TIME 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.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 homeassistant.util import dt as dt_util
from . import ( from . import (
@@ -20,8 +24,15 @@ from . import (
_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 Envisalink binary sensor devices.""" """Set up the Envisalink binary sensor devices."""
if not discovery_info:
return
configured_zones = discovery_info["zones"] configured_zones = discovery_info["zones"]
devices = [] devices = []

View File

@@ -1,9 +1,13 @@
"""Support for Envisalink sensors (shows panel info).""" """Support for Envisalink sensors (shows panel info)."""
from __future__ import annotations
import logging import logging
from homeassistant.components.sensor import SensorEntity 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.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import ( from . import (
CONF_PARTITIONNAME, CONF_PARTITIONNAME,
@@ -17,8 +21,15 @@ from . import (
_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:
"""Perform the setup for Envisalink sensor devices.""" """Perform the setup for Envisalink sensor devices."""
if not discovery_info:
return
configured_partitions = discovery_info["partitions"] configured_partitions = discovery_info["partitions"]
devices = [] devices = []