mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Cleanup of HomeWizard button platform (#85999)
This commit is contained in:
parent
13cfd60019
commit
2b037efee2
@ -1,7 +1,4 @@
|
||||
"""Support for HomeWizard buttons."""
|
||||
|
||||
import logging
|
||||
|
||||
from homeassistant.components.button import ButtonEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -13,23 +10,23 @@ from .coordinator import HWEnergyDeviceUpdateCoordinator
|
||||
from .entity import HomeWizardEntity
|
||||
from .helpers import homewizard_exception_handler
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up the Identify button."""
|
||||
coordinator: HWEnergyDeviceUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
features = await coordinator.api.features()
|
||||
if features.has_identify:
|
||||
if coordinator.data.features.has_identify:
|
||||
async_add_entities([HomeWizardIdentifyButton(coordinator, entry)])
|
||||
|
||||
|
||||
class HomeWizardIdentifyButton(HomeWizardEntity, ButtonEntity):
|
||||
"""Representation of a identify button."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_icon = "mdi:magnify"
|
||||
_attr_name = "Identify"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: HWEnergyDeviceUpdateCoordinator,
|
||||
@ -38,9 +35,6 @@ class HomeWizardIdentifyButton(HomeWizardEntity, ButtonEntity):
|
||||
"""Initialize button."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_unique_id = f"{entry.unique_id}_identify"
|
||||
self._attr_name = "Identify"
|
||||
self._attr_icon = "mdi:magnify"
|
||||
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
||||
@homewizard_exception_handler
|
||||
async def async_press(self) -> None:
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from datetime import timedelta
|
||||
|
||||
# Set up.
|
||||
from homewizard_energy.features import Features
|
||||
from homewizard_energy.models import Data, Device, State, System
|
||||
|
||||
from homeassistant.const import Platform
|
||||
@ -30,5 +30,6 @@ class DeviceResponseEntry:
|
||||
|
||||
device: Device
|
||||
data: Data
|
||||
features: Features
|
||||
state: State | None
|
||||
system: System | None = None
|
||||
|
@ -42,11 +42,11 @@ class HWEnergyDeviceUpdateCoordinator(DataUpdateCoordinator[DeviceResponseEntry]
|
||||
data = DeviceResponseEntry(
|
||||
device=await self.api.device(),
|
||||
data=await self.api.data(),
|
||||
features=await self.api.features(),
|
||||
state=await self.api.state(),
|
||||
)
|
||||
|
||||
features = await self.api.features()
|
||||
if features.has_system:
|
||||
if data.features.has_system:
|
||||
data.system = await self.api.system()
|
||||
|
||||
except RequestError as ex:
|
||||
|
Loading…
x
Reference in New Issue
Block a user