1
mirror of https://github.com/home-assistant/core synced 2024-10-04 07:58:43 +02:00
ha-core/homeassistant/components/doorbird/entity.py
J. Nick Koston f9a7c64106
Config flow for doorbird (#33165)
* Config flow for doorbird

* Discoverable via zeroconf

* Fix zeroconf test

* add missing return

* Add a test for legacy over ride url (will go away when refactored to cloud hooks)

* Update homeassistant/components/doorbird/__init__.py

Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>

* without getting the hooks its not so useful

* Update homeassistant/components/doorbird/config_flow.py

Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io>

* fix copy pasta

* remove identifiers since its in connections

* self review fixes

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-03-23 10:14:21 +01:00

37 lines
1.2 KiB
Python

"""The DoorBird integration base entity."""
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity import Entity
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_info = doorstation_info
self._doorstation = doorstation
self._mac_addr = get_mac_address_from_doorstation_info(doorstation_info)
@property
def device_info(self):
"""Doorbird device info."""
firmware = self._doorstation_info[DOORBIRD_INFO_KEY_FIRMWARE]
firmware_build = self._doorstation_info[DOORBIRD_INFO_KEY_BUILD_NUMBER]
return {
"connections": {(dr.CONNECTION_NETWORK_MAC, self._mac_addr)},
"name": self._doorstation.name,
"manufacturer": MANUFACTURER,
"sw_version": f"{firmware} {firmware_build}",
"model": self._doorstation_info[DOORBIRD_INFO_KEY_DEVICE_TYPE],
}