diff --git a/custom_components/reos_integration/__init__.py b/custom_components/reos_integration/__init__.py index 6cec6e6..a0db113 100755 --- a/custom_components/reos_integration/__init__.py +++ b/custom_components/reos_integration/__init__.py @@ -39,5 +39,5 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][username] = api - await hass.config_entries.async_forward_entry_setup(entry, "lock") + await hass.config_entries.async_forward_entry_setup(entry, "button") return True diff --git a/custom_components/reos_integration/lock.py b/custom_components/reos_integration/button.py similarity index 62% rename from custom_components/reos_integration/lock.py rename to custom_components/reos_integration/button.py index 148c48e..f459496 100644 --- a/custom_components/reos_integration/lock.py +++ b/custom_components/reos_integration/button.py @@ -1,6 +1,6 @@ from __future__ import annotations -from homeassistant.components.lock import LockEntity, LockEntityFeature +from homeassistant.components.button import ButtonEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -14,33 +14,20 @@ from .reos_api import ReosApi, ReosLockModel async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: AddEntitiesCallback) -> None: api: ReosApi = hass.data[DOMAIN][config_entry.data["username"]] - async_add_entities(ReosLock(lock) for lock in await api.get_locks()) + async_add_entities(ReosDoorButton(lock) for lock in await api.get_locks()) -class ReosLock(LockEntity): +class ReosDoorButton(ButtonEntity): def __init__(self, model: ReosLockModel) -> None: self._model = model self._attr_unique_id = f"reos_lock_{self._model.lock_id}" self._attr_name = self._model.display - self._attr_is_locked = False self._attr_device_class = "door" self._attr_icon = "mdi:door" - @property - def supported_features(self): - """Flag supported features.""" - return LockEntityFeature.OPEN + def press(self, **kwargs) -> None: + self.hass.create_task(self._model.open()) @property def device_info(self) -> DeviceInfo | None: return None - - async def async_open(self, **kwargs) -> None: - self.hass.async_create_task(self._model.open()) - - def unlock(self, **kwargs: cv.Any) -> None: - pass - - def lock(self, **kwargs: cv.Any) -> None: - pass -