2020-03-31 21:46:30 +00:00
|
|
|
"""Adapter to wrap the rachiopy api for home assistant."""
|
|
|
|
|
|
|
|
from homeassistant.helpers import device_registry
|
2021-10-22 15:40:13 +00:00
|
|
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
2020-03-31 21:46:30 +00:00
|
|
|
|
|
|
|
from .const import DEFAULT_NAME, DOMAIN
|
|
|
|
|
|
|
|
|
|
|
|
class RachioDevice(Entity):
|
|
|
|
"""Base class for rachio devices."""
|
|
|
|
|
|
|
|
def __init__(self, controller):
|
|
|
|
"""Initialize a Rachio device."""
|
|
|
|
super().__init__()
|
|
|
|
self._controller = controller
|
|
|
|
|
|
|
|
@property
|
|
|
|
def should_poll(self) -> bool:
|
|
|
|
"""Declare that this entity pushes its state to HA."""
|
|
|
|
return False
|
|
|
|
|
|
|
|
@property
|
2021-10-22 15:40:13 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-03-31 21:46:30 +00:00
|
|
|
"""Return the device_info of the device."""
|
2021-10-22 15:40:13 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
identifiers={
|
2020-08-27 11:56:20 +00:00
|
|
|
(
|
|
|
|
DOMAIN,
|
|
|
|
self._controller.serial_number,
|
|
|
|
)
|
|
|
|
},
|
2021-10-22 15:40:13 +00:00
|
|
|
connections={
|
2020-08-27 11:56:20 +00:00
|
|
|
(
|
|
|
|
device_registry.CONNECTION_NETWORK_MAC,
|
|
|
|
self._controller.mac_address,
|
|
|
|
)
|
2020-03-31 21:46:30 +00:00
|
|
|
},
|
2021-10-22 15:40:13 +00:00
|
|
|
name=self._controller.name,
|
|
|
|
model=self._controller.model,
|
|
|
|
manufacturer=DEFAULT_NAME,
|
|
|
|
configuration_url="https://app.rach.io",
|
|
|
|
)
|