mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 11:17:53 +00:00
Enable strict typing for the Elgato integration (#49920)
This commit is contained in:
parent
cbaeec2a4e
commit
dc46a213a7
@ -10,6 +10,7 @@ homeassistant.components.brother.*
|
|||||||
homeassistant.components.calendar.*
|
homeassistant.components.calendar.*
|
||||||
homeassistant.components.cover.*
|
homeassistant.components.cover.*
|
||||||
homeassistant.components.device_automation.*
|
homeassistant.components.device_automation.*
|
||||||
|
homeassistant.components.elgato.*
|
||||||
homeassistant.components.frontend.*
|
homeassistant.components.frontend.*
|
||||||
homeassistant.components.geo_location.*
|
homeassistant.components.geo_location.*
|
||||||
homeassistant.components.group.*
|
homeassistant.components.group.*
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.components.light import (
|
|||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_NAME, ATTR_TEMPERATURE
|
from homeassistant.const import ATTR_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
@ -23,7 +23,6 @@ from .const import (
|
|||||||
ATTR_IDENTIFIERS,
|
ATTR_IDENTIFIERS,
|
||||||
ATTR_MANUFACTURER,
|
ATTR_MANUFACTURER,
|
||||||
ATTR_MODEL,
|
ATTR_MODEL,
|
||||||
ATTR_ON,
|
|
||||||
ATTR_SOFTWARE_VERSION,
|
ATTR_SOFTWARE_VERSION,
|
||||||
DATA_ELGATO_CLIENT,
|
DATA_ELGATO_CLIENT,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -53,7 +52,7 @@ class ElgatoLight(LightEntity):
|
|||||||
self,
|
self,
|
||||||
elgato: Elgato,
|
elgato: Elgato,
|
||||||
info: Info,
|
info: Info,
|
||||||
):
|
) -> None:
|
||||||
"""Initialize Elgato Key Light."""
|
"""Initialize Elgato Key Light."""
|
||||||
self._info: Info = info
|
self._info: Info = info
|
||||||
self._state: State | None = None
|
self._state: State | None = None
|
||||||
@ -110,23 +109,23 @@ class ElgatoLight(LightEntity):
|
|||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off the light."""
|
"""Turn off the light."""
|
||||||
await self.async_turn_on(on=False)
|
try:
|
||||||
|
await self.elgato.light(on=False)
|
||||||
|
except ElgatoError:
|
||||||
|
_LOGGER.error("An error occurred while updating the Elgato Key Light")
|
||||||
|
self._state = None
|
||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn on the light."""
|
"""Turn on the light."""
|
||||||
data: dict[str, bool | int] = {ATTR_ON: True}
|
temperature = kwargs.get(ATTR_COLOR_TEMP)
|
||||||
|
brightness = None
|
||||||
if ATTR_ON in kwargs:
|
|
||||||
data[ATTR_ON] = kwargs[ATTR_ON]
|
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
|
||||||
data[ATTR_TEMPERATURE] = kwargs[ATTR_COLOR_TEMP]
|
|
||||||
|
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
data[ATTR_BRIGHTNESS] = round((kwargs[ATTR_BRIGHTNESS] / 255) * 100)
|
brightness = round((kwargs[ATTR_BRIGHTNESS] / 255) * 100)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.elgato.light(**data)
|
await self.elgato.light(
|
||||||
|
on=True, brightness=brightness, temperature=temperature
|
||||||
|
)
|
||||||
except ElgatoError:
|
except ElgatoError:
|
||||||
_LOGGER.error("An error occurred while updating the Elgato Key Light")
|
_LOGGER.error("An error occurred while updating the Elgato Key Light")
|
||||||
self._state = None
|
self._state = None
|
||||||
@ -135,7 +134,7 @@ class ElgatoLight(LightEntity):
|
|||||||
"""Update Elgato entity."""
|
"""Update Elgato entity."""
|
||||||
restoring = self._state is None
|
restoring = self._state is None
|
||||||
try:
|
try:
|
||||||
self._state: State = await self.elgato.state()
|
self._state = await self.elgato.state()
|
||||||
if restoring:
|
if restoring:
|
||||||
_LOGGER.info("Connection restored")
|
_LOGGER.info("Connection restored")
|
||||||
except ElgatoError as err:
|
except ElgatoError as err:
|
||||||
|
@ -56,7 +56,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
|||||||
"homeassistant.components.dynalite.*",
|
"homeassistant.components.dynalite.*",
|
||||||
"homeassistant.components.eafm.*",
|
"homeassistant.components.eafm.*",
|
||||||
"homeassistant.components.edl21.*",
|
"homeassistant.components.edl21.*",
|
||||||
"homeassistant.components.elgato.*",
|
|
||||||
"homeassistant.components.elkm1.*",
|
"homeassistant.components.elkm1.*",
|
||||||
"homeassistant.components.emonitor.*",
|
"homeassistant.components.emonitor.*",
|
||||||
"homeassistant.components.enphase_envoy.*",
|
"homeassistant.components.enphase_envoy.*",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user