diff --git a/homeassistant/components/brunt/__init__.py b/homeassistant/components/brunt/__init__.py index f189be63920..979b3f5b005 100644 --- a/homeassistant/components/brunt/__init__.py +++ b/homeassistant/components/brunt/__init__.py @@ -5,7 +5,7 @@ import logging from aiohttp.client_exceptions import ClientResponseError, ServerDisconnectedError import async_timeout -from brunt import BruntClientAsync +from brunt import BruntClientAsync, Thing from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME @@ -36,7 +36,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: f"Brunt could not connect with username: {entry.data[CONF_USERNAME]}." ) from exc - async def async_update_data(): + async def async_update_data() -> dict[str | None, Thing]: """Fetch data from the Brunt endpoint for all Things. Error 403 is the API response for any kind of authentication error (failed password or email) @@ -54,6 +54,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if err.status == 401: _LOGGER.warning("Device not found, will reload Brunt integration") await hass.config_entries.async_reload(entry.entry_id) + raise UpdateFailed from err coordinator = DataUpdateCoordinator( hass, diff --git a/homeassistant/components/brunt/cover.py b/homeassistant/components/brunt/cover.py index 489229622b2..599008adc60 100644 --- a/homeassistant/components/brunt/cover.py +++ b/homeassistant/components/brunt/cover.py @@ -1,7 +1,7 @@ """Support for Brunt Blind Engine covers.""" from __future__ import annotations -from typing import Any +from typing import Any, Optional from aiohttp.client_exceptions import ClientResponseError from brunt import BruntClientAsync, Thing @@ -42,7 +42,9 @@ async def async_setup_entry( ) -> None: """Set up the brunt platform.""" bapi: BruntClientAsync = hass.data[DOMAIN][entry.entry_id][DATA_BAPI] - coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id][DATA_COOR] + coordinator: DataUpdateCoordinator[dict[str | None, Thing]] = hass.data[DOMAIN][ + entry.entry_id + ][DATA_COOR] async_add_entities( BruntDevice(coordinator, serial, thing, bapi, entry.entry_id) @@ -50,7 +52,9 @@ async def async_setup_entry( ) -class BruntDevice(CoordinatorEntity, CoverEntity): +class BruntDevice( + CoordinatorEntity[DataUpdateCoordinator[dict[Optional[str], Thing]]], CoverEntity +): """ Representation of a Brunt cover device. @@ -65,8 +69,8 @@ class BruntDevice(CoordinatorEntity, CoverEntity): def __init__( self, - coordinator: DataUpdateCoordinator, - serial: str, + coordinator: DataUpdateCoordinator[dict[str | None, Thing]], + serial: str | None, thing: Thing, bapi: BruntClientAsync, entry_id: str, @@ -84,7 +88,7 @@ class BruntDevice(CoordinatorEntity, CoverEntity): self._attr_device_class = CoverDeviceClass.BLIND self._attr_attribution = ATTRIBUTION self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, self._attr_unique_id)}, + identifiers={(DOMAIN, self._attr_unique_id)}, # type: ignore[arg-type] name=self._attr_name, via_device=(DOMAIN, self._entry_id), manufacturer="Brunt",