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
20 changed files with 111 additions and 103 deletions

View File

@ -1,4 +1,4 @@
"""Support for ISY994 binary sensors."""
"""Support for ISY binary sensors."""
from __future__ import annotations
from datetime import datetime, timedelta
@ -56,7 +56,7 @@ DEVICE_PARENT_REQUIRED = [
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the ISY994 binary sensor platform."""
"""Set up the ISY binary sensor platform."""
entities: list[
ISYInsteonBinarySensorEntity
| ISYBinarySensorEntity
@ -219,7 +219,7 @@ def _detect_device_type_and_class(
class ISYBinarySensorEntity(ISYNodeEntity, BinarySensorEntity):
"""Representation of a basic ISY994 binary sensor device."""
"""Representation of a basic ISY binary sensor device."""
def __init__(
self,
@ -227,13 +227,13 @@ class ISYBinarySensorEntity(ISYNodeEntity, BinarySensorEntity):
force_device_class: BinarySensorDeviceClass | None = None,
unknown_state: bool | None = None,
) -> None:
"""Initialize the ISY994 binary sensor device."""
"""Initialize the ISY binary sensor device."""
super().__init__(node)
self._device_class = force_device_class
@property
def is_on(self) -> bool | None:
"""Get whether the ISY994 binary sensor device is on."""
"""Get whether the ISY binary sensor device is on."""
if self._node.status == ISY_VALUE_UNKNOWN:
return None
return bool(self._node.status)
@ -248,7 +248,7 @@ class ISYBinarySensorEntity(ISYNodeEntity, BinarySensorEntity):
class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
"""Representation of an ISY994 Insteon binary sensor device.
"""Representation of an ISY Insteon binary sensor device.
Often times, a single device is represented by multiple nodes in the ISY,
allowing for different nuances in how those devices report their on and
@ -262,7 +262,7 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
force_device_class: BinarySensorDeviceClass | None = None,
unknown_state: bool | None = None,
) -> None:
"""Initialize the ISY994 binary sensor device."""
"""Initialize the ISY binary sensor device."""
super().__init__(node, force_device_class)
self._negative_node: Node | None = None
self._heartbeat_device: ISYBinarySensorHeartbeat | None = None
@ -374,7 +374,7 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
@property
def is_on(self) -> bool | None:
"""Get whether the ISY994 binary sensor device is on.
"""Get whether the ISY binary sensor device is on.
Insteon leak sensors set their primary node to On when the state is
DRY, not WET, so we invert the binary state if the user indicates
@ -391,7 +391,7 @@ class ISYInsteonBinarySensorEntity(ISYBinarySensorEntity):
class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity):
"""Representation of the battery state of an ISY994 sensor."""
"""Representation of the battery state of an ISY sensor."""
def __init__(
self,
@ -401,7 +401,7 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity):
| ISYBinarySensorHeartbeat
| ISYBinarySensorProgramEntity,
) -> None:
"""Initialize the ISY994 binary sensor device.
"""Initialize the ISY binary sensor device.
Computed state is set to UNKNOWN unless the ISY provided a valid
state. See notes above regarding ISY Sensor status on ISY restart.
@ -479,7 +479,7 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Get whether the ISY994 binary sensor device is on.
"""Get whether the ISY binary sensor device is on.
Note: This method will return false if the current state is UNKNOWN
which occurs after a restart until the first heartbeat or control
@ -501,7 +501,7 @@ class ISYBinarySensorHeartbeat(ISYNodeEntity, BinarySensorEntity):
class ISYBinarySensorProgramEntity(ISYProgramEntity, BinarySensorEntity):
"""Representation of an ISY994 binary sensor program.
"""Representation of an ISY binary sensor program.
This does not need all of the subnode logic in the device version of binary
sensors.
@ -509,5 +509,5 @@ class ISYBinarySensorProgramEntity(ISYProgramEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""Get whether the ISY994 binary sensor device is on."""
"""Get whether the ISY binary sensor device is on."""
return bool(self._node.status)