Beispiel #1
0
    def __init__(
        self,
        config_entry: ConfigEntry,
        frigate_config: dict[str, Any],
        cam_name: str,
        obj_name: str,
    ) -> None:
        """Construct a FrigateMqttSnapshots camera."""
        self._cam_name = cam_name
        self._obj_name = obj_name
        self._last_image: bytes | None = None

        FrigateMQTTEntity.__init__(
            self,
            config_entry,
            frigate_config,
            {
                "topic": (
                    f"{frigate_config['mqtt']['topic_prefix']}"
                    f"/{self._cam_name}/{self._obj_name}/snapshot"
                ),
                "encoding": None,
            },
        )
        Camera.__init__(self)
Beispiel #2
0
    def __init__(
        self,
        latitude,
        longitude,
        tzname,
        configdir,
        tmpdir,
        show_constellations,
        show_time,
        show_legend,
        constellations,
        planets,
        north_up,
    ):
        Camera.__init__(self)
        from . import bodies

        self.sky = bodies.Sky(
            (latitude, longitude),
            tzname,
            show_constellations,
            show_time,
            show_legend,
            constellations,
            planets,
            north_up,
        )
        self._loaded = False
        self._configdir = configdir
        self._tmpdir = tmpdir
Beispiel #3
0
    def __init__(
        self, config_entry: ConfigEntry, cam_name: str, camera_config: dict[str, Any]
    ) -> None:
        """Initialize a Frigate camera."""
        FrigateEntity.__init__(self, config_entry)
        Camera.__init__(self)
        self._cam_name = cam_name
        self._camera_config = camera_config
        self._url = config_entry.data[CONF_URL]
        self._stream_enabled = self._camera_config["rtmp"]["enabled"]

        streaming_template = config_entry.options.get(
            CONF_RTMP_URL_TEMPLATE, ""
        ).strip()

        if streaming_template:
            # Can't use homeassistant.helpers.template as it requires hass which
            # is not available in the constructor, so use direct jinja2
            # template instead. This means templates cannot access HomeAssistant
            # state, but rather only the camera config.
            self._stream_source = Template(streaming_template).render(
                **self._camera_config
            )
        else:
            self._stream_source = f"rtmp://{URL(self._url).host}/live/{self._cam_name}"
Beispiel #4
0
    def __init__(
        self,
        data_handler: NetatmoDataHandler,
        camera_id: str,
        camera_type: str,
        home_id: str,
        quality: str,
    ) -> None:
        """Set up for access to the Netatmo camera images."""
        Camera.__init__(self)
        super().__init__(data_handler)

        self._data_classes.append(
            {"name": CAMERA_DATA_CLASS_NAME, SIGNAL_NAME: CAMERA_DATA_CLASS_NAME}
        )

        self._id = camera_id
        self._home_id = home_id
        self._device_name = self._data.get_camera(camera_id=camera_id)["name"]
        self._attr_name = f"{MANUFACTURER} {self._device_name}"
        self._model = camera_type
        self._netatmo_type = TYPE_SECURITY
        self._attr_unique_id = f"{self._id}-{self._model}"
        self._quality = quality
        self._vpnurl: str | None = None
        self._localurl: str | None = None
        self._status: str | None = None
        self._sd_status: str | None = None
        self._alim_status: str | None = None
        self._is_local: str | None = None
        self._light_state = None
 def __init__(self, device):
     """Initialize a camera for a Skybell device."""
     SkybellDevice.__init__(self, device)
     Camera.__init__(self)
     self._name = self._device.name
     self._url = None
     self._response = None
Beispiel #6
0
    def __init__(self, hass, config):
        """Initialize a Reolink camera."""
        ReolinkEntity.__init__(self, hass, config)
        Camera.__init__(self)

        self._hass = hass
        self._ffmpeg = self._hass.data[DATA_FFMPEG]
        self._last_image = None
        self._ptz_commands = {
            "AUTO": "Auto",
            "DOWN": "Down",
            "FOCUSDEC": "FocusDec",
            "FOCUSINC": "FocusInc",
            "LEFT": "Left",
            "LEFTDOWN": "LeftDown",
            "LEFTUP": "LeftUp",
            "RIGHT": "Right",
            "RIGHTDOWN": "RightDown",
            "RIGHTUP": "RightUp",
            "STOP": "Stop",
            "TOPOS": "ToPos",
            "UP": "Up",
            "ZOOMDEC": "ZoomDec",
            "ZOOMINC": "ZoomInc",
        }
        self._daynight_modes = {
            "AUTO": "Auto",
            "COLOR": "Color",
            "BLACKANDWHITE": "Black&White",
        }
Beispiel #7
0
    def __init__(
        self,
        hass: HomeAssistant,
        coordinator: EzvizDataUpdateCoordinator,
        idx: int,
        camera_username: str,
        camera_password: str,
        camera_rtsp_stream: str | None,
        local_rtsp_port: int | None,
        ffmpeg_arguments: str | None,
    ) -> None:
        """Initialize a Ezviz security camera."""
        super().__init__(coordinator)
        Camera.__init__(self)
        self._username = camera_username
        self._password = camera_password
        self._rtsp_stream = camera_rtsp_stream
        self._idx = idx
        self._ffmpeg = hass.data[DATA_FFMPEG]
        self._local_rtsp_port = local_rtsp_port
        self._ffmpeg_arguments = ffmpeg_arguments

        self._serial = self.coordinator.data[self._idx]["serial"]
        self._name = self.coordinator.data[self._idx]["name"]
        self._local_ip = self.coordinator.data[self._idx]["local_ip"]
Beispiel #8
0
 def __init__(self, device):
     """Initialize a camera for a Skybell device."""
     SkybellDevice.__init__(self, device)
     Camera.__init__(self)
     self._name = self._device.name
     self._url = None
     self._response = None
Beispiel #9
0
    def __init__(
        self,
        hass,
        coordinator,
        idx,
        camera_username,
        camera_password,
        camera_rtsp_stream,
        local_rtsp_port,
        ffmpeg_arguments,
    ):
        """Initialize a Ezviz security camera."""
        super().__init__(coordinator)
        Camera.__init__(self)
        self._username = camera_username
        self._password = camera_password
        self._rtsp_stream = camera_rtsp_stream
        self._idx = idx
        self._ffmpeg = hass.data[DATA_FFMPEG]
        self._local_rtsp_port = local_rtsp_port
        self._ffmpeg_arguments = ffmpeg_arguments

        self._serial = self.coordinator.data[self._idx]["serial"]
        self._name = self.coordinator.data[self._idx]["name"]
        self._local_ip = self.coordinator.data[self._idx]["local_ip"]
Beispiel #10
0
    def __init__(
        self,
        data_handler,
        camera_id,
        camera_type,
        home_id,
        quality,
    ):
        """Set up for access to the Netatmo camera images."""
        Camera.__init__(self)
        super().__init__(data_handler)

        self._data_classes.append({
            "name": CAMERA_DATA_CLASS_NAME,
            SIGNAL_NAME: CAMERA_DATA_CLASS_NAME
        })

        self._id = camera_id
        self._home_id = home_id
        self._device_name = self._data.get_camera(
            camera_id=camera_id).get("name")
        self._name = f"{MANUFACTURER} {self._device_name}"
        self._model = camera_type
        self._unique_id = f"{self._id}-{self._model}"
        self._quality = quality
        self._vpnurl = None
        self._localurl = None
        self._status = None
        self._sd_status = None
        self._alim_status = None
        self._is_local = None
        self._light_state = None
    def __init__(
        self,
        data_handler,
        data_class,
        camera_id,
        camera_type,
        home_id,
        quality,
    ):
        """Set up for access to the Netatmo camera images."""
        Camera.__init__(self)
        NetatmoBase.__init__(self, data_handler)

        self._data_classes.append({"name": data_class})

        self._camera_id = camera_id
        self._home_id = home_id
        self._camera_name = self._data.get_camera(
            camera_id=camera_id).get("name")
        self._name = f"{MANUFACTURER} {self._camera_name}"
        self._camera_type = camera_type
        self._unique_id = f"{self._camera_id}-{self._camera_type}"
        self._quality = quality
        self._vpnurl = None
        self._localurl = None
        self._status = None
        self._sd_status = None
        self._alim_status = None
        self._is_local = None
Beispiel #12
0
 def __init__(
     self,
     hass: HomeAssistant,
     coordinator: CanaryDataUpdateCoordinator,
     location_id: str,
     device: Device,
     ffmpeg_args: str,
 ) -> None:
     """Initialize a Canary security camera."""
     super().__init__(coordinator)
     Camera.__init__(self)
     self._ffmpeg: FFmpegManager = get_ffmpeg_manager(hass)
     self._ffmpeg_arguments = ffmpeg_args
     self._location_id = location_id
     self._device = device
     self._live_stream_session: LiveStreamSession | None = None
     self._attr_name = device.name
     self._attr_unique_id = str(device.device_id)
     self._attr_device_info = DeviceInfo(
         identifiers={(DOMAIN, str(device.device_id))},
         manufacturer=MANUFACTURER,
         model=device.device_type["name"],
         name=device.name,
     )
     self._image: bytes | None = None
     self._expires_at = dt_util.utcnow()
     _LOGGER.debug("%s %s has been initialized", self.name,
                   device.device_type["name"])
Beispiel #13
0
 def __init__(
     self,
     hass: HomeAssistant,
     coordinator: EzvizDataUpdateCoordinator,
     serial: str,
     camera_username: str,
     camera_password: str | None,
     camera_rtsp_stream: str | None,
     local_rtsp_port: int,
     ffmpeg_arguments: str | None,
 ) -> None:
     """Initialize a Ezviz security camera."""
     super().__init__(coordinator, serial)
     Camera.__init__(self)
     self.stream_options[CONF_USE_WALLCLOCK_AS_TIMESTAMPS] = True
     self._username = camera_username
     self._password = camera_password
     self._rtsp_stream = camera_rtsp_stream
     self._local_rtsp_port = local_rtsp_port
     self._ffmpeg_arguments = ffmpeg_arguments
     self._ffmpeg = get_ffmpeg_manager(hass)
     self._attr_unique_id = serial
     self._attr_name = self.data["name"]
     if camera_password:
         self._attr_supported_features = CameraEntityFeature.STREAM
Beispiel #14
0
 def __init__(self, data: AbodeSystem, device: AbodeDev,
              event: Event) -> None:
     """Initialize the Abode device."""
     AbodeDevice.__init__(self, data, device)
     Camera.__init__(self)
     self._event = event
     self._response: Response | None = None
Beispiel #15
0
 def __init__(
     self,
     device: TuyaDevice,
     device_manager: TuyaDeviceManager,
 ) -> None:
     """Init Tuya Camera."""
     super().__init__(device, device_manager)
     CameraEntity.__init__(self)
Beispiel #16
0
 def __init__(
     self,
     coordinator: SkybellDataUpdateCoordinator,
     description: EntityDescription,
 ) -> None:
     """Initialize a camera for a Skybell device."""
     super().__init__(coordinator, description)
     Camera.__init__(self)
Beispiel #17
0
    def __init__(self, latitude, longitude, tzname, configdir, tmpdir):
        Camera.__init__(self)
        from . import bodies

        self.sky = bodies.Sky((latitude, longitude), tzname)
        self._loaded = False
        self._configdir = configdir
        self._tmpdir = tmpdir
Beispiel #18
0
 def __init__(self, device, profile):
     """Initialize ONVIF camera entity."""
     ONVIFBaseEntity.__init__(self, device, profile)
     Camera.__init__(self)
     self.stream_options[
         CONF_RTSP_TRANSPORT] = device.config_entry.options.get(
             CONF_RTSP_TRANSPORT)
     self._stream_uri = None
     self._snapshot_uri = None
Beispiel #19
0
 def __init__(
     self,
     device: TuyaDevice,
     device_manager: TuyaDeviceManager,
 ) -> None:
     """Init Tuya Camera."""
     super().__init__(device, device_manager)
     CameraEntity.__init__(self)
     self._attr_model = device.product_name
Beispiel #20
0
    def __init__(self, hass, controller, name, url):
        """Initialize the Tentalux camera."""
        TentaluxDevice.__init__(self, controller, name)
        Camera.__init__(self)
        self.hass = hass
        self._still_image_url = url
        self._frame_interval = 1 / FRAMERATE

        self._last_image = None
Beispiel #21
0
 def __init__(self, client: MotionHttpClient, id: str):
     MotionCamera.__init__(self, client, id)
     self._unique_id = f"{client.unique_id}_{self.camera_id}"
     self._recording = False
     self._triggered = False
     self._state = STATE_PROBLEM if not self.connected else STATE_PAUSED if self.paused else STATE_IDLE
     self._attr_extra_state_attributes = {}
     self._camera_image = None # cached copy
     self._available = True
     Camera.__init__(self)
Beispiel #22
0
 def __init__(self, device, profile):
     """Initialize ONVIF camera entity."""
     ONVIFBaseEntity.__init__(self, device, profile)
     Camera.__init__(self)
     self.stream_options[
         CONF_RTSP_TRANSPORT] = device.config_entry.options.get(
             CONF_RTSP_TRANSPORT)
     self._basic_auth = (device.config_entry.data.get(CONF_SNAPSHOT_AUTH) ==
                         HTTP_BASIC_AUTHENTICATION)
     self._stream_uri = None
Beispiel #23
0
    def __init__(self, hass, config: dict, miot_service: MiotService):
        name = config[CONF_NAME]
        host = config[CONF_HOST]
        token = config[CONF_TOKEN]
        _LOGGER.info('Initializing %s with host %s (token %s...)', name, host,
                     token[:5])

        self._miot_service = miot_service
        mapping = miot_service.spec.services_mapping(
            ENTITY_DOMAIN,
            'camera_control',
            'p2p_stream',
            'camera_stream_for_google_home',
            'camera_stream_for_amazon_alexa',
        ) or {}
        mapping.update(miot_service.mapping())
        self._device = MiotDevice(mapping, host, token)
        super().__init__(name, self._device, miot_service, config=config)
        Camera.__init__(self)
        self._add_entities = config.get('add_entities') or {}

        self._prop_motion_tracking = miot_service.get_property(
            'motion_tracking')
        self._srv_stream = None
        self._act_start_stream = None
        self._prop_stream_address = None
        self._prop_expiration_time = None
        for s in [
                'camera_stream_for_google_home',
                'camera_stream_for_amazon_alexa'
        ]:
            srv = miot_service.spec.get_service(s)
            if not srv:
                continue
            act = srv.get_action('start_hls_stream', 'start_rtsp_stream')
            if act:
                self._srv_stream = srv
                self._act_start_stream = act
                self._prop_stream_address = srv.get_property('stream_address')
                self._prop_expiration_time = srv.get_property(
                    'expiration_time')
                break

        if self._prop_power:
            self._supported_features |= SUPPORT_ON_OFF
        if self._prop_stream_address:
            self._supported_features |= SUPPORT_STREAM

        self._state_attrs.update({'entity_class': self.__class__.__name__})
        self._last_image = None
        self._last_url = None
        self._url_expiration = 0
        self._extra_arguments = None
        self._manager = hass.data.get(DATA_FFMPEG)
        self._subs = {}
Beispiel #24
0
 def __init__(self, device, camera_type, name=None):
     """Initialize a camera for a Skybell device."""
     self._type = camera_type
     SkybellDevice.__init__(self, device)
     Camera.__init__(self)
     if name is not None:
         self._name = "{} {}".format(self._device.name, name)
     else:
         self._name = self._device.name
     self._url = None
     self._response = None
Beispiel #25
0
 def __init__(self, device, camera_type, name=None):
     """Initialize a camera for a Skybell device."""
     self._type = camera_type
     SkybellDevice.__init__(self, device)
     Camera.__init__(self)
     if name is not None:
         self._name = "{} {}".format(self._device.name, name)
     else:
         self._name = self._device.name
     self._url = None
     self._response = None
Beispiel #26
0
    def __init__(self, config, discovery_hash):
        """Initialize the MQTT Camera."""
        self._config = config
        self._unique_id = config.get(CONF_UNIQUE_ID)
        self._sub_state = None

        self._qos = 0
        self._last_image = None

        Camera.__init__(self)
        MqttDiscoveryUpdate.__init__(self, discovery_hash,
                                     self.discovery_update)
Beispiel #27
0
    def __init__(self, config, discovery_hash):
        """Initialize the MQTT Camera."""
        self._config = config
        self._unique_id = config.get(CONF_UNIQUE_ID)
        self._sub_state = None

        self._qos = 0
        self._last_image = None

        Camera.__init__(self)
        MqttDiscoveryUpdate.__init__(self, discovery_hash,
                                     self.discovery_update)
Beispiel #28
0
    def __init__(self, coordinator):
        """Initialize the camera."""
        super().__init__(coordinator)
        Camera.__init__(self)

        self.radar_object = coordinator.ec_data
        self._attr_name = f"{coordinator.config_entry.title} Radar"
        self._attr_unique_id = f"{coordinator.config_entry.unique_id}-radar"
        self._attr_attribution = self.radar_object.metadata["attribution"]
        self._attr_entity_registry_enabled_default = False

        self.content_type = "image/gif"
Beispiel #29
0
    def __init__(self, ffmpeg, device, coordinator):
        """Initialize."""
        super().__init__(device, coordinator)
        Camera.__init__(self)

        self._async_unsub_dispatcher_connect = None
        self._ffmpeg = ffmpeg
        self._ffmpeg_arguments = DEFAULT_FFMPEG_ARGUMENTS
        self._ffmpeg_image_frame = ImageFrame(ffmpeg.binary)
        self._ffmpeg_stream = CameraMjpeg(ffmpeg.binary)
        self._last_image = None
        self._last_image_url = None
        self._stream_url = None
Beispiel #30
0
 def __init__(self, hass, coordinator, location_id, device, timeout, ffmpeg_args):
     """Initialize a Canary security camera."""
     super().__init__(coordinator)
     Camera.__init__(self)
     self._ffmpeg = hass.data[DATA_FFMPEG]
     self._ffmpeg_arguments = ffmpeg_args
     self._location_id = location_id
     self._device = device
     self._device_id = device.device_id
     self._device_name = device.name
     self._device_type_name = device.device_type["name"]
     self._timeout = timeout
     self._live_stream_session = None
Beispiel #31
0
    def __init__(self, coordinator):
        """Initialize the camera."""
        super().__init__(coordinator)
        Camera.__init__(self)

        self.radar_object = coordinator.ec_data
        self._attr_name = f"{coordinator.config_entry.title} Radar"
        self._attr_unique_id = f"{coordinator.config_entry.unique_id}-radar"
        self._attr_attribution = self.radar_object.metadata["attribution"]

        self.content_type = "image/gif"
        self.image = None
        self.observation_time = None
Beispiel #32
0
    def __init__(
        self,
        coordinator: VerisureDataUpdateCoordinator,
        serial_number: str,
        directory_path: str,
    ):
        """Initialize Verisure File Camera component."""
        super().__init__(coordinator)
        Camera.__init__(self)

        self.serial_number = serial_number
        self._directory_path = directory_path
        self._image = None
        self._image_id = None
Beispiel #33
0
    def __init__(self, config, config_entry, discovery_hash):
        """Initialize the MQTT Camera."""
        self._config = config
        self._unique_id = config.get(CONF_UNIQUE_ID)
        self._sub_state = None

        self._qos = 0
        self._last_image = None

        device_config = config.get(CONF_DEVICE)

        Camera.__init__(self)
        MqttDiscoveryUpdate.__init__(self, discovery_hash,
                                     self.discovery_update)
        MqttEntityDeviceInfo.__init__(self, device_config, config_entry)
Beispiel #34
0
 def __init__(self, data, device, event):
     """Initialize the Abode device."""
     AbodeDevice.__init__(self, data, device)
     Camera.__init__(self)
     self._event = event
     self._response = None
Beispiel #35
0
 def __init__(self, entry_id: str, component_key: str, key: int):
     """Initialize."""
     Camera.__init__(self)
     EsphomeEntity.__init__(self, entry_id, component_key, key)
     self._image_cond = asyncio.Condition()