2020-03-23 09:14:21 +00:00
|
|
|
"""The DoorBird integration base entity."""
|
|
|
|
|
|
|
|
from homeassistant.helpers import device_registry as dr
|
2021-10-22 15:00:00 +00:00
|
|
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
2020-03-23 09:14:21 +00:00
|
|
|
|
|
|
|
from .const import (
|
|
|
|
DOORBIRD_INFO_KEY_BUILD_NUMBER,
|
|
|
|
DOORBIRD_INFO_KEY_DEVICE_TYPE,
|
|
|
|
DOORBIRD_INFO_KEY_FIRMWARE,
|
|
|
|
MANUFACTURER,
|
|
|
|
)
|
|
|
|
from .util import get_mac_address_from_doorstation_info
|
|
|
|
|
|
|
|
|
|
|
|
class DoorBirdEntity(Entity):
|
|
|
|
"""Base class for doorbird entities."""
|
|
|
|
|
|
|
|
def __init__(self, doorstation, doorstation_info):
|
|
|
|
"""Initialize the entity."""
|
|
|
|
super().__init__()
|
|
|
|
self._doorstation = doorstation
|
|
|
|
self._mac_addr = get_mac_address_from_doorstation_info(doorstation_info)
|
|
|
|
|
2022-01-23 03:53:44 +00:00
|
|
|
firmware = doorstation_info[DOORBIRD_INFO_KEY_FIRMWARE]
|
|
|
|
firmware_build = doorstation_info[DOORBIRD_INFO_KEY_BUILD_NUMBER]
|
|
|
|
self._attr_device_info = DeviceInfo(
|
2021-10-28 12:32:53 +00:00
|
|
|
configuration_url="https://webadmin.doorbird.com/",
|
2021-10-22 15:00:00 +00:00
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, self._mac_addr)},
|
|
|
|
manufacturer=MANUFACTURER,
|
2022-01-23 03:53:44 +00:00
|
|
|
model=doorstation_info[DOORBIRD_INFO_KEY_DEVICE_TYPE],
|
2021-10-22 15:00:00 +00:00
|
|
|
name=self._doorstation.name,
|
|
|
|
sw_version=f"{firmware} {firmware_build}",
|
|
|
|
)
|