Typing tweak to the Elgato integration (#47471)
This commit is contained in:
parent
b3c33fc1be
commit
02e723f206
2 changed files with 14 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
"""Config flow to configure the Elgato Key Light integration."""
|
"""Config flow to configure the Elgato Key Light integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any
|
||||||
|
|
||||||
from elgato import Elgato, ElgatoError
|
from elgato import Elgato, ElgatoError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -25,8 +25,8 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
serial_number: str
|
serial_number: str
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: Dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> Dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Handle a flow initiated by the user."""
|
"""Handle a flow initiated by the user."""
|
||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self._async_show_setup_form()
|
return self._async_show_setup_form()
|
||||||
|
@ -42,8 +42,8 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
return self._async_create_entry()
|
return self._async_create_entry()
|
||||||
|
|
||||||
async def async_step_zeroconf(
|
async def async_step_zeroconf(
|
||||||
self, discovery_info: Dict[str, Any]
|
self, discovery_info: dict[str, Any]
|
||||||
) -> Dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
self.host = discovery_info[CONF_HOST]
|
self.host = discovery_info[CONF_HOST]
|
||||||
self.port = discovery_info[CONF_PORT]
|
self.port = discovery_info[CONF_PORT]
|
||||||
|
@ -59,15 +59,15 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_zeroconf_confirm(
|
async def async_step_zeroconf_confirm(
|
||||||
self, _: Dict[str, Any] | None = None
|
self, _: dict[str, Any] | None = None
|
||||||
) -> Dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Handle a flow initiated by zeroconf."""
|
"""Handle a flow initiated by zeroconf."""
|
||||||
return self._async_create_entry()
|
return self._async_create_entry()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_show_setup_form(
|
def _async_show_setup_form(
|
||||||
self, errors: Dict[str, str] | None = None
|
self, errors: dict[str, str] | None = None
|
||||||
) -> Dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Show the setup form to the user."""
|
"""Show the setup form to the user."""
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="user",
|
step_id="user",
|
||||||
|
@ -81,7 +81,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||||
)
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_create_entry(self) -> Dict[str, Any]:
|
def _async_create_entry(self) -> dict[str, Any]:
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=self.serial_number,
|
title=self.serial_number,
|
||||||
data={
|
data={
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Callable, Dict, List
|
from typing import Any, Callable
|
||||||
|
|
||||||
from elgato import Elgato, ElgatoError, Info, State
|
from elgato import Elgato, ElgatoError, Info, State
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ SCAN_INTERVAL = timedelta(seconds=10)
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistantType,
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
async_add_entities: Callable[[List[Entity], bool], None],
|
async_add_entities: Callable[[list[Entity], bool], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Elgato Key Light based on a config entry."""
|
"""Set up Elgato Key Light based on a config entry."""
|
||||||
elgato: Elgato = hass.data[DOMAIN][entry.entry_id][DATA_ELGATO_CLIENT]
|
elgato: Elgato = hass.data[DOMAIN][entry.entry_id][DATA_ELGATO_CLIENT]
|
||||||
|
@ -116,7 +116,7 @@ class ElgatoLight(LightEntity):
|
||||||
|
|
||||||
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}
|
data: dict[str, bool | int] = {ATTR_ON: True}
|
||||||
|
|
||||||
if ATTR_ON in kwargs:
|
if ATTR_ON in kwargs:
|
||||||
data[ATTR_ON] = kwargs[ATTR_ON]
|
data[ATTR_ON] = kwargs[ATTR_ON]
|
||||||
|
@ -149,7 +149,7 @@ class ElgatoLight(LightEntity):
|
||||||
self._temperature = state.temperature
|
self._temperature = state.temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> Dict[str, Any]:
|
def device_info(self) -> dict[str, Any]:
|
||||||
"""Return device information about this Elgato Key Light."""
|
"""Return device information about this Elgato Key Light."""
|
||||||
return {
|
return {
|
||||||
ATTR_IDENTIFIERS: {(DOMAIN, self._info.serial_number)},
|
ATTR_IDENTIFIERS: {(DOMAIN, self._info.serial_number)},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue