(self, config, force_cache=False)
Update images for camera.
Update images for camera.
Update images for camera .
def update_images(self, config, force_cache=False):
        """Update images for camera."""
        new_thumbnail = None
        thumb_addr = None
        if config.get("thumbnail", False):
            thumb_addr = config["thumbnail"]
        else:
            _LOGGER.warning("Could not find thumbnail for camera %s", self.name)

        if thumb_addr is not None:
            new_thumbnail = f"{self.sync.urls.base_url}{thumb_addr}.jpg"

        try:
            self.motion_detected = self.sync.motion[self.name]
        except KeyError:
            self.motion_detected = False

        clip_addr = None
        try:
            clip_addr = self.sync.last_record[self.name]["clip"]
            self.last_record = self.sync.last_record[self.name]["time"]
            self.clip = f"{self.sync.urls.base_url}{clip_addr}"
        except KeyError:
            pass

        # If the thumbnail or clip have changed, update the cache
        update_cached_image = False
        if new_thumbnail != self.thumbnail or self._cached_image is None:
            update_cached_image = True
        self.thumbnail = new_thumbnail

        update_cached_video = False
        if self._cached_video is None or self.motion_detected:
            update_cached_video = True

        if new_thumbnail is not None and (update_cached_image or force_cache):
            self._cached_image = self.get_media()

        if clip_addr is not None and (update_cached_video or force_cache):
            self._cached_video = self.get_media(media_type="video")
def update_images ( self , config , force_cache = False ) : new_thumbnail = None thumb_addr = None if config . get ( "thumbnail" , False ) : thumb_addr = config [ "thumbnail" ] else : _LOGGER . warning ( "Could not find thumbnail for camera %s" , self . name ) if thumb_addr is not None : new_thumbnail = f"{self.sync.urls.base_url}{thumb_addr}.jpg" try : self . motion_detected = self . sync . motion [ self . name ] except KeyError : self . motion_detected = False clip_addr = None try : clip_addr = self . sync . last_record [ self . name ] [ "clip" ] self . last_record = self . sync . last_record [ self . name ] [ "time" ] self . clip = f"{self.sync.urls.base_url}{clip_addr}" except KeyError : pass # If the thumbnail or clip have changed, update the cache update_cached_image = False if new_thumbnail != self . thumbnail or self . _cached_image is None : update_cached_image = True self . thumbnail = new_thumbnail update_cached_video = False if self . _cached_video is None or self . motion_detected : update_cached_video = True if new_thumbnail is not None and ( update_cached_image or force_cache ) : self . _cached_image = self . get_media ( ) if clip_addr is not None and ( update_cached_video or force_cache ) : self . _cached_video = self . get_media ( media_type = "video" )