Add update listener type hints to broadlink (#65413)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2022-02-03 10:00:30 +01:00 committed by GitHub
parent 23ee8adf59
commit b587201654
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,8 +12,9 @@ from broadlink.exceptions import (
NetworkTimeoutError,
)
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntry
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
@ -64,13 +65,15 @@ class BroadlinkDevice:
return self.update_manager.available
@staticmethod
async def async_update(hass, entry):
async def async_update(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update the device and related entities.
Triggered when the device is renamed on the frontend.
"""
device_registry = dr.async_get(hass)
assert entry.unique_id
device_entry = device_registry.async_get_device({(DOMAIN, entry.unique_id)})
assert device_entry
device_registry.async_update_device(device_entry.id, name=entry.title)
await hass.config_entries.async_reload(entry.entry_id)