mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add basic type hints to broadlink (#62879)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
d8dabd305c
commit
2aa8a86126
@ -3,6 +3,10 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .device import BroadlinkDevice
|
from .device import BroadlinkDevice
|
||||||
from .heartbeat import BroadlinkHeartbeat
|
from .heartbeat import BroadlinkHeartbeat
|
||||||
@ -17,13 +21,13 @@ class BroadlinkData:
|
|||||||
heartbeat: BroadlinkHeartbeat | None = None
|
heartbeat: BroadlinkHeartbeat | None = None
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Broadlink integration."""
|
"""Set up the Broadlink integration."""
|
||||||
hass.data[DOMAIN] = BroadlinkData()
|
hass.data[DOMAIN] = BroadlinkData()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, entry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a Broadlink device from a config entry."""
|
"""Set up a Broadlink device from a config entry."""
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
|
|
||||||
@ -35,7 +39,7 @@ async def async_setup_entry(hass, entry):
|
|||||||
return await device.async_setup()
|
return await device.async_setup()
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass, entry):
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
data = hass.data[DOMAIN]
|
data = hass.data[DOMAIN]
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ from homeassistant.components.light import (
|
|||||||
COLOR_MODE_UNKNOWN,
|
COLOR_MODE_UNKNOWN,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import BroadlinkEntity
|
from .entity import BroadlinkEntity
|
||||||
@ -25,7 +28,11 @@ BROADLINK_COLOR_MODE_WHITE = 1
|
|||||||
BROADLINK_COLOR_MODE_SCENES = 2
|
BROADLINK_COLOR_MODE_SCENES = 2
|
||||||
|
|
||||||
|
|
||||||
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 the Broadlink light."""
|
"""Set up the Broadlink light."""
|
||||||
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
||||||
lights = []
|
lights = []
|
||||||
|
@ -31,9 +31,11 @@ from homeassistant.components.remote import (
|
|||||||
SUPPORT_LEARN_COMMAND,
|
SUPPORT_LEARN_COMMAND,
|
||||||
RemoteEntity,
|
RemoteEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF
|
from homeassistant.const import STATE_OFF
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
@ -85,7 +87,11 @@ SERVICE_DELETE_SCHEMA = COMMAND_SCHEMA.extend(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 a Broadlink remote."""
|
"""Set up a Broadlink remote."""
|
||||||
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
||||||
remote = BroadlinkRemote(
|
remote = BroadlinkRemote(
|
||||||
|
@ -7,6 +7,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
@ -15,6 +16,8 @@ from homeassistant.const import (
|
|||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import BroadlinkEntity
|
from .entity import BroadlinkEntity
|
||||||
@ -85,7 +88,11 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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 the Broadlink sensor."""
|
"""Set up the Broadlink sensor."""
|
||||||
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
||||||
sensor_data = device.update_manager.coordinator.data
|
sensor_data = device.update_manager.coordinator.data
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""Support for Broadlink switches."""
|
"""Support for Broadlink switches."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -10,6 +12,7 @@ from homeassistant.components.switch import (
|
|||||||
SwitchDeviceClass,
|
SwitchDeviceClass,
|
||||||
SwitchEntity,
|
SwitchEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_COMMAND_OFF,
|
CONF_COMMAND_OFF,
|
||||||
CONF_COMMAND_ON,
|
CONF_COMMAND_ON,
|
||||||
@ -22,8 +25,11 @@ from homeassistant.const import (
|
|||||||
STATE_ON,
|
STATE_ON,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
|
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.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .entity import BroadlinkEntity
|
from .entity import BroadlinkEntity
|
||||||
@ -59,7 +65,12 @@ PLATFORM_SCHEMA = vol.All(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
"""Import the device and set up custom switches.
|
"""Import the device and set up custom switches.
|
||||||
|
|
||||||
This is for backward compatibility.
|
This is for backward compatibility.
|
||||||
@ -84,10 +95,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
import_device(hass, host)
|
import_device(hass, host)
|
||||||
|
|
||||||
|
|
||||||
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 the Broadlink switch."""
|
"""Set up the Broadlink switch."""
|
||||||
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
device = hass.data[DOMAIN].devices[config_entry.entry_id]
|
||||||
switches = []
|
switches: list[BroadlinkSwitch] = []
|
||||||
|
|
||||||
if device.api.type in {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"}:
|
if device.api.type in {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"}:
|
||||||
platform_data = hass.data[DOMAIN].platforms.get(Platform.SWITCH, {})
|
platform_data = hass.data[DOMAIN].platforms.get(Platform.SWITCH, {})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user