core/homeassistant/components/rachio/entity.py

43 lines
1.2 KiB
Python
Raw Normal View History

"""Adapter to wrap the rachiopy api for home assistant."""
from homeassistant.helpers import device_registry
from homeassistant.helpers.entity import DeviceInfo, 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) -> DeviceInfo:
"""Return the device_info of the device."""
return DeviceInfo(
identifiers={
2020-08-27 11:56:20 +00:00
(
DOMAIN,
self._controller.serial_number,
)
},
connections={
2020-08-27 11:56:20 +00:00
(
device_registry.CONNECTION_NETWORK_MAC,
self._controller.mac_address,
)
},
name=self._controller.name,
model=self._controller.model,
manufacturer=DEFAULT_NAME,
configuration_url="https://app.rach.io",
)