Add device info to FOSCAM (#98167)
parent
2a78d7fa2d
commit
3e56d27bf7
|
@ -11,9 +11,17 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import CONF_RTSP_PORT, CONF_STREAM, LOGGER, SERVICE_PTZ, SERVICE_PTZ_PRESET
|
||||
from .const import (
|
||||
CONF_RTSP_PORT,
|
||||
CONF_STREAM,
|
||||
DOMAIN,
|
||||
LOGGER,
|
||||
SERVICE_PTZ,
|
||||
SERVICE_PTZ_PRESET,
|
||||
)
|
||||
|
||||
DIR_UP = "up"
|
||||
DIR_DOWN = "down"
|
||||
|
@ -94,12 +102,14 @@ async def async_setup_entry(
|
|||
class HassFoscamCamera(Camera):
|
||||
"""An implementation of a Foscam IP camera."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, camera: FoscamCamera, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize a Foscam camera."""
|
||||
super().__init__()
|
||||
|
||||
self._foscam_session = camera
|
||||
self._attr_name = config_entry.title
|
||||
self._username = config_entry.data[CONF_USERNAME]
|
||||
self._password = config_entry.data[CONF_PASSWORD]
|
||||
self._stream = config_entry.data[CONF_STREAM]
|
||||
|
@ -107,6 +117,10 @@ class HassFoscamCamera(Camera):
|
|||
self._rtsp_port = config_entry.data[CONF_RTSP_PORT]
|
||||
if self._rtsp_port:
|
||||
self._attr_supported_features = CameraEntityFeature.STREAM
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, config_entry.entry_id)},
|
||||
manufacturer="Foscam",
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle entity addition to hass."""
|
||||
|
|
Loading…
Reference in New Issue