Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device info to FOSCAM #98167

Merged
merged 5 commits into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions homeassistant/components/foscam/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
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"
Expand Down Expand Up @@ -94,19 +102,25 @@ 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]
self._attr_unique_id = config_entry.entry_id
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."""
Expand Down