1 """Base classes for ONVIF entities."""
3 from __future__
import annotations
8 from .const
import DOMAIN
9 from .device
import ONVIFDevice
13 """Base class common to all ONVIF entities."""
15 def __init__(self, device: ONVIFDevice) ->
None:
16 """Initialize the ONVIF entity."""
17 self.device: ONVIFDevice = device
21 """Return True if device is available."""
22 return self.device.available
26 """Return MAC or serial, for unique_id generation.
28 MAC address is not always available, and given the number
29 of non-conformant ONVIF devices we have historically supported,
30 we cannot guarantee serial number either. Due to this, we have
31 adopted an either/or approach in the config entry setup, and can
32 guarantee that one or the other will be populated.
33 See: https://github.com/home-assistant/core/issues/35883
36 self.device.info.mac
or self.device.info.serial_number
41 """Return a device description for device registry."""
42 connections: set[tuple[str, str]] = set()
43 if self.device.info.mac:
44 connections = {(CONNECTION_NETWORK_MAC, self.device.info.mac)}
46 connections=connections,
48 manufacturer=self.device.info.manufacturer,
49 model=self.device.info.model,
50 name=self.device.name,
51 sw_version=self.device.info.fw_version,
52 configuration_url=f
"http://{self.device.host}:{self.device.port}",
None __init__(self, ONVIFDevice device)
DeviceInfo device_info(self)