Improve init type hints in enocean (#92176)
parent
8c64eda58f
commit
67a7de1869
|
@ -7,6 +7,7 @@ import voluptuous as vol
|
|||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASSES_SCHEMA,
|
||||
PLATFORM_SCHEMA,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICE_CLASS, CONF_ID, CONF_NAME
|
||||
|
@ -37,9 +38,9 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Binary Sensor platform for EnOcean."""
|
||||
dev_id = config.get(CONF_ID)
|
||||
dev_name = config.get(CONF_NAME)
|
||||
device_class = config.get(CONF_DEVICE_CLASS)
|
||||
dev_id: list[int] = config[CONF_ID]
|
||||
dev_name: str = config[CONF_NAME]
|
||||
device_class: BinarySensorDeviceClass | None = config.get(CONF_DEVICE_CLASS)
|
||||
|
||||
add_entities([EnOceanBinarySensor(dev_id, dev_name, device_class)])
|
||||
|
||||
|
@ -52,7 +53,12 @@ class EnOceanBinarySensor(EnOceanEntity, BinarySensorEntity):
|
|||
- F6-02-02 (Light and Blind Control - Application Style 1)
|
||||
"""
|
||||
|
||||
def __init__(self, dev_id, dev_name, device_class):
|
||||
def __init__(
|
||||
self,
|
||||
dev_id: list[int],
|
||||
dev_name: str,
|
||||
device_class: BinarySensorDeviceClass | None,
|
||||
) -> None:
|
||||
"""Initialize the EnOcean binary sensor."""
|
||||
super().__init__(dev_id, dev_name)
|
||||
self._device_class = device_class
|
||||
|
|
|
@ -11,7 +11,7 @@ from .const import SIGNAL_RECEIVE_MESSAGE, SIGNAL_SEND_MESSAGE
|
|||
class EnOceanEntity(Entity):
|
||||
"""Parent class for all entities associated with the EnOcean component."""
|
||||
|
||||
def __init__(self, dev_id, dev_name="EnOcean device"):
|
||||
def __init__(self, dev_id: list[int], dev_name: str) -> None:
|
||||
"""Initialize the device."""
|
||||
self.dev_id = dev_id
|
||||
self.dev_name = dev_name
|
||||
|
|
|
@ -41,9 +41,9 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the EnOcean light platform."""
|
||||
sender_id = config.get(CONF_SENDER_ID)
|
||||
dev_name = config.get(CONF_NAME)
|
||||
dev_id = config.get(CONF_ID)
|
||||
sender_id: list[int] = config[CONF_SENDER_ID]
|
||||
dev_name: str = config[CONF_NAME]
|
||||
dev_id: list[int] = config[CONF_ID]
|
||||
|
||||
add_entities([EnOceanLight(sender_id, dev_id, dev_name)])
|
||||
|
||||
|
@ -54,7 +54,7 @@ class EnOceanLight(EnOceanEntity, LightEntity):
|
|||
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||
|
||||
def __init__(self, sender_id, dev_id, dev_name):
|
||||
def __init__(self, sender_id: list[int], dev_id: list[int], dev_name: str) -> None:
|
||||
"""Initialize the EnOcean light source."""
|
||||
super().__init__(dev_id, dev_name)
|
||||
self._on_state = False
|
||||
|
|
|
@ -117,16 +117,16 @@ def setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up an EnOcean sensor device."""
|
||||
dev_id = config[CONF_ID]
|
||||
dev_name = config[CONF_NAME]
|
||||
sensor_type = config[CONF_DEVICE_CLASS]
|
||||
dev_id: list[int] = config[CONF_ID]
|
||||
dev_name: str = config[CONF_NAME]
|
||||
sensor_type: str = config[CONF_DEVICE_CLASS]
|
||||
|
||||
entities: list[EnOceanSensor] = []
|
||||
if sensor_type == SENSOR_TYPE_TEMPERATURE:
|
||||
temp_min = config[CONF_MIN_TEMP]
|
||||
temp_max = config[CONF_MAX_TEMP]
|
||||
range_from = config[CONF_RANGE_FROM]
|
||||
range_to = config[CONF_RANGE_TO]
|
||||
temp_min: int = config[CONF_MIN_TEMP]
|
||||
temp_max: int = config[CONF_MAX_TEMP]
|
||||
range_from: int = config[CONF_RANGE_FROM]
|
||||
range_to: int = config[CONF_RANGE_TO]
|
||||
entities = [
|
||||
EnOceanTemperatureSensor(
|
||||
dev_id,
|
||||
|
@ -155,7 +155,10 @@ class EnOceanSensor(EnOceanEntity, RestoreEntity, SensorEntity):
|
|||
"""Representation of an EnOcean sensor device such as a power meter."""
|
||||
|
||||
def __init__(
|
||||
self, dev_id, dev_name, description: EnOceanSensorEntityDescription
|
||||
self,
|
||||
dev_id: list[int],
|
||||
dev_name: str,
|
||||
description: EnOceanSensorEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize the EnOcean sensor device."""
|
||||
super().__init__(dev_id, dev_name)
|
||||
|
@ -217,14 +220,14 @@ class EnOceanTemperatureSensor(EnOceanSensor):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
dev_id,
|
||||
dev_name,
|
||||
dev_id: list[int],
|
||||
dev_name: str,
|
||||
description: EnOceanSensorEntityDescription,
|
||||
*,
|
||||
scale_min,
|
||||
scale_max,
|
||||
range_from,
|
||||
range_to,
|
||||
scale_min: int,
|
||||
scale_max: int,
|
||||
range_from: int,
|
||||
range_to: int,
|
||||
) -> None:
|
||||
"""Initialize the EnOcean temperature sensor device."""
|
||||
super().__init__(dev_id, dev_name, description)
|
||||
|
|
|
@ -65,9 +65,9 @@ async def async_setup_platform(
|
|||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the EnOcean switch platform."""
|
||||
channel = config.get(CONF_CHANNEL)
|
||||
dev_id = config.get(CONF_ID)
|
||||
dev_name = config.get(CONF_NAME)
|
||||
channel: int = config[CONF_CHANNEL]
|
||||
dev_id: list[int] = config[CONF_ID]
|
||||
dev_name: str = config[CONF_NAME]
|
||||
|
||||
_migrate_to_new_unique_id(hass, dev_id, channel)
|
||||
async_add_entities([EnOceanSwitch(dev_id, dev_name, channel)])
|
||||
|
@ -76,7 +76,7 @@ async def async_setup_platform(
|
|||
class EnOceanSwitch(EnOceanEntity, SwitchEntity):
|
||||
"""Representation of an EnOcean switch device."""
|
||||
|
||||
def __init__(self, dev_id, dev_name, channel):
|
||||
def __init__(self, dev_id: list[int], dev_name: str, channel: int) -> None:
|
||||
"""Initialize the EnOcean switch device."""
|
||||
super().__init__(dev_id, dev_name)
|
||||
self._light = None
|
||||
|
|
Loading…
Reference in New Issue