Extract foscam base entity for reuse (#108893)
* Extract foscam base entity for reuse * Cleanup * More cleanup * Cleanup constructor * Use more constants
This commit is contained in:
parent
b5c1d3feeb
commit
0013f184b3
3 changed files with 34 additions and 14 deletions
30
homeassistant/components/foscam/entity.py
Normal file
30
homeassistant/components/foscam/entity.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""Component providing basic support for Foscam IP cameras."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.const import ATTR_HW_VERSION, ATTR_MODEL, ATTR_SW_VERSION
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .coordinator import FoscamCoordinator
|
||||
|
||||
|
||||
class FoscamEntity(CoordinatorEntity[FoscamCoordinator]):
|
||||
"""Base entity for Foscam camera."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: FoscamCoordinator,
|
||||
entry_id: str,
|
||||
) -> None:
|
||||
"""Initialize the base Foscam entity."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, entry_id)},
|
||||
manufacturer="Foscam",
|
||||
)
|
||||
if dev_info := coordinator.data.get("dev_info"):
|
||||
self._attr_device_info[ATTR_MODEL] = dev_info["productName"]
|
||||
self._attr_device_info[ATTR_SW_VERSION] = dev_info["firmwareVer"]
|
||||
self._attr_device_info[ATTR_HW_VERSION] = dev_info["hardwareVer"]
|
Loading…
Add table
Add a link
Reference in a new issue