mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
ElkM1 integration add types, part 2 (#70210)
This commit is contained in:
parent
2641ecdec8
commit
24e817a173
@ -83,6 +83,10 @@ homeassistant.components.dunehd.*
|
|||||||
homeassistant.components.efergy.*
|
homeassistant.components.efergy.*
|
||||||
homeassistant.components.elgato.*
|
homeassistant.components.elgato.*
|
||||||
homeassistant.components.elkm1.__init__
|
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.esphome.*
|
||||||
homeassistant.components.energy.*
|
homeassistant.components.energy.*
|
||||||
homeassistant.components.evil_genius_labs.*
|
homeassistant.components.evil_genius_labs.*
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
"""Support for control of ElkM1 lighting (X10, UPB, etc)."""
|
"""Support for control of ElkM1 lighting (X10, UPB, etc)."""
|
||||||
from __future__ import annotations
|
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 (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
COLOR_MODE_BRIGHTNESS,
|
COLOR_MODE_BRIGHTNESS,
|
||||||
@ -32,14 +38,15 @@ class ElkLight(ElkEntity, LightEntity):
|
|||||||
|
|
||||||
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||||
_attr_supported_color_modes = {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."""
|
"""Initialize the Elk light."""
|
||||||
super().__init__(element, elk, elk_data)
|
super().__init__(element, elk, elk_data)
|
||||||
self._brightness = self._element.status
|
self._brightness = self._element.status
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self) -> int:
|
||||||
"""Get the brightness."""
|
"""Get the brightness."""
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|
||||||
@ -48,14 +55,14 @@ class ElkLight(ElkEntity, LightEntity):
|
|||||||
"""Get the current brightness."""
|
"""Get the current brightness."""
|
||||||
return self._brightness != 0
|
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
|
status = self._element.status if self._element.status != 1 else 100
|
||||||
self._brightness = round(status * 2.55)
|
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."""
|
"""Turn on the light."""
|
||||||
self._element.level(round(kwargs.get(ATTR_BRIGHTNESS, 255) / 2.55))
|
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."""
|
"""Turn off the light."""
|
||||||
self._element.level(0)
|
self._element.level(0)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
"""Support for control of ElkM1 outputs (relays)."""
|
"""Support for control of ElkM1 outputs (relays)."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from elkm1_lib.outputs import Output
|
from elkm1_lib.outputs import Output
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
@ -35,10 +37,10 @@ class ElkOutput(ElkAttachedEntity, SwitchEntity):
|
|||||||
"""Get the current output status."""
|
"""Get the current output status."""
|
||||||
return self._element.output_on
|
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."""
|
"""Turn on the output."""
|
||||||
self._element.turn_on(0)
|
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."""
|
"""Turn off the output."""
|
||||||
self._element.turn_off()
|
self._element.turn_off()
|
||||||
|
44
mypy.ini
44
mypy.ini
@ -715,6 +715,50 @@ no_implicit_optional = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = 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.*]
|
[mypy-homeassistant.components.esphome.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user