mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Improve error handling of powerview hub maintenance, remove invalid device classes (#73395)
This commit is contained in:
parent
5854dfa84f
commit
9ae713f128
@ -7,11 +7,7 @@ from typing import Any, Final
|
||||
|
||||
from aiopvapi.resources.shade import BaseShade, factory as PvShade
|
||||
|
||||
from homeassistant.components.button import (
|
||||
ButtonDeviceClass,
|
||||
ButtonEntity,
|
||||
ButtonEntityDescription,
|
||||
)
|
||||
from homeassistant.components.button import ButtonEntity, ButtonEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
@ -50,7 +46,6 @@ BUTTONS: Final = [
|
||||
key="calibrate",
|
||||
name="Calibrate",
|
||||
icon="mdi:swap-vertical-circle-outline",
|
||||
device_class=ButtonDeviceClass.UPDATE,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
press_action=lambda shade: shade.calibrate(),
|
||||
),
|
||||
@ -58,7 +53,6 @@ BUTTONS: Final = [
|
||||
key="identify",
|
||||
name="Identify",
|
||||
icon="mdi:crosshairs-question",
|
||||
device_class=ButtonDeviceClass.UPDATE,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
press_action=lambda shade: shade.jog(),
|
||||
),
|
||||
|
@ -36,9 +36,19 @@ class PowerviewShadeUpdateCoordinator(DataUpdateCoordinator[PowerviewShadeData])
|
||||
|
||||
async def _async_update_data(self) -> PowerviewShadeData:
|
||||
"""Fetch data from shade endpoint."""
|
||||
|
||||
async with async_timeout.timeout(10):
|
||||
shade_entries = await self.shades.get_resources()
|
||||
|
||||
if isinstance(shade_entries, bool):
|
||||
# hub returns boolean on a 204/423 empty response (maintenance)
|
||||
# continual polling results in inevitable error
|
||||
raise UpdateFailed("Powerview Hub is undergoing maintenance")
|
||||
|
||||
if not shade_entries:
|
||||
raise UpdateFailed("Failed to fetch new shade data")
|
||||
|
||||
# only update if shade_entries is valid
|
||||
self.data.store_group_data(shade_entries[SHADE_DATA])
|
||||
|
||||
return self.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user