Update ISY994 integration to be model agnostic (#85017)

This commit is contained in:
shbatm 2023-01-02 18:22:40 -06:00 committed by GitHub
parent 5d6ca6dd44
commit 240e1fd8f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 111 additions and 103 deletions

View file

@ -1,4 +1,4 @@
"""Support for ISY994 covers."""
"""Support for ISY covers."""
from __future__ import annotations
from typing import Any, cast
@ -30,7 +30,7 @@ from .helpers import migrate_old_unique_ids
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the ISY994 cover platform."""
"""Set up the ISY cover platform."""
hass_isy_data = hass.data[ISY994_DOMAIN][entry.entry_id]
entities: list[ISYCoverEntity | ISYCoverProgramEntity] = []
for node in hass_isy_data[ISY994_NODES][COVER]:
@ -44,7 +44,7 @@ async def async_setup_entry(
class ISYCoverEntity(ISYNodeEntity, CoverEntity):
"""Representation of an ISY994 cover device."""
"""Representation of an ISY cover device."""
_attr_supported_features = (
CoverEntityFeature.OPEN
@ -63,19 +63,19 @@ class ISYCoverEntity(ISYNodeEntity, CoverEntity):
@property
def is_closed(self) -> bool | None:
"""Get whether the ISY994 cover device is closed."""
"""Get whether the ISY cover device is closed."""
if self._node.status == ISY_VALUE_UNKNOWN:
return None
return bool(self._node.status == 0)
async def async_open_cover(self, **kwargs: Any) -> None:
"""Send the open cover command to the ISY994 cover device."""
"""Send the open cover command to the ISY cover device."""
val = 100 if self._node.uom == UOM_BARRIER else None
if not await self._node.turn_on(val=val):
_LOGGER.error("Unable to open the cover")
async def async_close_cover(self, **kwargs: Any) -> None:
"""Send the close cover command to the ISY994 cover device."""
"""Send the close cover command to the ISY cover device."""
if not await self._node.turn_off():
_LOGGER.error("Unable to close the cover")
@ -89,19 +89,19 @@ class ISYCoverEntity(ISYNodeEntity, CoverEntity):
class ISYCoverProgramEntity(ISYProgramEntity, CoverEntity):
"""Representation of an ISY994 cover program."""
"""Representation of an ISY cover program."""
@property
def is_closed(self) -> bool:
"""Get whether the ISY994 cover program is closed."""
"""Get whether the ISY cover program is closed."""
return bool(self._node.status)
async def async_open_cover(self, **kwargs: Any) -> None:
"""Send the open cover command to the ISY994 cover program."""
"""Send the open cover command to the ISY cover program."""
if not await self._actions.run_then():
_LOGGER.error("Unable to open the cover")
async def async_close_cover(self, **kwargs: Any) -> None:
"""Send the close cover command to the ISY994 cover program."""
"""Send the close cover command to the ISY cover program."""
if not await self._actions.run_else():
_LOGGER.error("Unable to close the cover")