Read out device data via ui
This commit is contained in:
		| @ -1,11 +1,18 @@ | ||||
| import logging | ||||
| import urllib | ||||
| from urllib.parse import quote | ||||
|  | ||||
| from homeassistant.components.button import ButtonEntityDescription, ButtonEntity | ||||
| from homeassistant.config_entries import ConfigEntry | ||||
| from pyhon import Hon | ||||
| from pyhon.appliance import HonAppliance | ||||
|  | ||||
| from homeassistant.const import EntityCategory | ||||
| from .const import DOMAIN | ||||
| from .hon import HonCoordinator, HonEntity | ||||
|  | ||||
| _LOGGER = logging.getLogger(__name__) | ||||
|  | ||||
| BUTTONS: dict[str, tuple[ButtonEntityDescription, ...]] = { | ||||
|     "OV": ( | ||||
|         ButtonEntityDescription( | ||||
| @ -41,6 +48,7 @@ async def async_setup_entry(hass, entry: ConfigEntry, async_add_entities) -> Non | ||||
|                 appliances.extend( | ||||
|                     [HonButtonEntity(hass, coordinator, entry, device, description)] | ||||
|                 ) | ||||
|         appliances.extend([HonFeatureRequestButton(hass, coordinator, entry, device)]) | ||||
|  | ||||
|     async_add_entities(appliances) | ||||
|  | ||||
| @ -58,3 +66,18 @@ class HonButtonEntity(HonEntity, ButtonEntity): | ||||
|  | ||||
|     async def async_press(self) -> None: | ||||
|         await self._device.commands[self.entity_description.key].send() | ||||
|  | ||||
|  | ||||
| class HonFeatureRequestButton(HonEntity, ButtonEntity): | ||||
|     def __init__(self, hass, coordinator, entry, device: HonAppliance) -> None: | ||||
|         super().__init__(hass, entry, coordinator, device) | ||||
|  | ||||
|         self._device = device | ||||
|         self._attr_unique_id = f"{super().unique_id}_log_device_info" | ||||
|         self._attr_icon = "mdi:information" | ||||
|         self._attr_name = "Log Device Info" | ||||
|         self._attr_entity_category = EntityCategory.DIAGNOSTIC | ||||
|         self._attr_entity_registry_enabled_default = False | ||||
|  | ||||
|     async def async_press(self) -> None: | ||||
|         _LOGGER.error("Device Info:\n" + self._device.diagnose) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user