mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
ElkM1 integration add types, part 2 (#70210)
This commit is contained in:
@ -83,6 +83,10 @@ homeassistant.components.dunehd.*
|
||||
homeassistant.components.efergy.*
|
||||
homeassistant.components.elgato.*
|
||||
homeassistant.components.elkm1.__init__
|
||||
homeassistant.components.elkm1.discovery
|
||||
homeassistant.components.elkm1.light
|
||||
homeassistant.components.elkm1.scene
|
||||
homeassistant.components.elkm1.switch
|
||||
homeassistant.components.esphome.*
|
||||
homeassistant.components.energy.*
|
||||
homeassistant.components.evil_genius_labs.*
|
||||
|
@ -1,6 +1,12 @@
|
||||
"""Support for control of ElkM1 lighting (X10, UPB, etc)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from elkm1_lib.elements import Element
|
||||
from elkm1_lib.elk import Elk
|
||||
from elkm1_lib.lights import Light
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
@ -32,14 +38,15 @@ class ElkLight(ElkEntity, LightEntity):
|
||||
|
||||
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||
_element: Light
|
||||
|
||||
def __init__(self, element, elk, elk_data):
|
||||
def __init__(self, element: Element, elk: Elk, elk_data: dict[str, Any]) -> None:
|
||||
"""Initialize the Elk light."""
|
||||
super().__init__(element, elk, elk_data)
|
||||
self._brightness = self._element.status
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
def brightness(self) -> int:
|
||||
"""Get the brightness."""
|
||||
return self._brightness
|
||||
|
||||
@ -48,14 +55,14 @@ class ElkLight(ElkEntity, LightEntity):
|
||||
"""Get the current brightness."""
|
||||
return self._brightness != 0
|
||||
|
||||
def _element_changed(self, element, changeset):
|
||||
def _element_changed(self, element: Element, changeset: Any) -> None:
|
||||
status = self._element.status if self._element.status != 1 else 100
|
||||
self._brightness = round(status * 2.55)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the light."""
|
||||
self._element.level(round(kwargs.get(ATTR_BRIGHTNESS, 255) / 2.55))
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the light."""
|
||||
self._element.level(0)
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for control of ElkM1 outputs (relays)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from elkm1_lib.outputs import Output
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
@ -35,10 +37,10 @@ class ElkOutput(ElkAttachedEntity, SwitchEntity):
|
||||
"""Get the current output status."""
|
||||
return self._element.output_on
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the output."""
|
||||
self._element.turn_on(0)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the output."""
|
||||
self._element.turn_off()
|
||||
|
44
mypy.ini
44
mypy.ini
@ -715,6 +715,50 @@ no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.elkm1.discovery]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.elkm1.light]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.elkm1.scene]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.elkm1.switch]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
disallow_subclassing_any = true
|
||||
disallow_untyped_calls = true
|
||||
disallow_untyped_decorators = true
|
||||
disallow_untyped_defs = true
|
||||
no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.esphome.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Reference in New Issue
Block a user