2020-03-31 21:46:30 +00:00
|
|
|
"""Adapter to wrap the rachiopy api for home assistant."""
|
|
|
|
|
|
|
|
from homeassistant.helpers import device_registry
|
|
|
|
from homeassistant.helpers.entity import Entity
|
|
|
|
|
|
|
|
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
|
|
|
|
def device_info(self):
|
|
|
|
"""Return the device_info of the device."""
|
|
|
|
return {
|
2020-08-27 11:56:20 +00:00
|
|
|
"identifiers": {
|
|
|
|
(
|
|
|
|
DOMAIN,
|
|
|
|
self._controller.serial_number,
|
|
|
|
)
|
|
|
|
},
|
2020-03-31 21:46:30 +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
|
|
|
},
|
|
|
|
"name": self._controller.name,
|
|
|
|
"model": self._controller.model,
|
|
|
|
"manufacturer": DEFAULT_NAME,
|
|
|
|
}
|