hass-core/homeassistant/components/wmspro/entity.py
Marc Hörsken 587ebd5d47
Add new integration for WMS WebControl pro using local API (#124176)
* Add new integration for WMS WebControl pro using local API

Warema recently released a new local API for their WMS hub
called "WebControl pro". This integration makes use of the
new local API via a new dedicated Python library pywmspro.

For now this integration only supports awnings as covers.
But pywmspro is device-agnostic to ease future extensions.

* Incorporated review feedback from joostlek

Thanks a lot!

* Incorporated more review feedback from joostlek

Thanks a lot!

* Incorporated more review feedback from joostlek

Thanks a lot!

* Fix

* Follow-up fix

* Improve handling of DHCP discovery

* Further test improvements suggested by joostlek, thanks!

---------

Co-authored-by: Joostlek <joostlek@outlook.com>
2024-09-16 16:07:43 +02:00

43 lines
1.3 KiB
Python

"""Generic entity for the WMS WebControl pro API integration."""
from __future__ import annotations
from wmspro.destination import Destination
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity import Entity
from .const import ATTRIBUTION, DOMAIN, MANUFACTURER
class WebControlProGenericEntity(Entity):
"""Foundation of all WMS based entities."""
_attr_attribution = ATTRIBUTION
_attr_has_entity_name = True
_attr_name = None
def __init__(self, config_entry_id: str, dest: Destination) -> None:
"""Initialize the entity with destination channel."""
dest_id_str = str(dest.id)
self._dest = dest
self._attr_unique_id = dest_id_str
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, dest_id_str)},
manufacturer=MANUFACTURER,
model=dest.animationType.name,
name=dest.name,
serial_number=dest_id_str,
suggested_area=dest.room.name,
via_device=(DOMAIN, config_entry_id),
configuration_url=f"http://{dest.host}/control",
)
async def async_update(self) -> None:
"""Update the entity."""
await self._dest.refresh()
@property
def available(self) -> bool:
"""Return if entity is available."""
return self._dest.available