Пример #1
0
    def start(self):
        """Initialize the system."""
        response = api.request_syncmodule(self.blink, self.network_id)
        self.summary = response['syncmodule']
        self.sync_id = self.summary['id']
        self.network_id = self.summary['network_id']
        self.serial = self.summary['serial']
        self.status = self.summary['status']

        self.events = self.get_events()

        self.homescreen = api.request_homescreen(self.blink)

        self.network_info = api.request_network_status(self.blink,
                                                       self.network_id)

        camera_info = self.get_camera_info()
        for camera_config in camera_info:
            name = camera_config['name']
            self.cameras[name] = BlinkCamera(self)

        self.videos = self.get_videos()
        for camera_config in camera_info:
            name = camera_config['name']
            if name in self.cameras:
                self.cameras[name].update(camera_config, force_cache=True)
Пример #2
0
 def sync_initialize(self):
     """Initialize a sync module."""
     response = api.request_syncmodule(self.blink, self.network_id)
     try:
         self.summary = response["syncmodule"]
         self.network_id = self.summary["network_id"]
     except (TypeError, KeyError):
         _LOGGER.error(
             "Could not retrieve sync module information with response: %s",
             response)
         return False
     return response
Пример #3
0
    def start(self):
        """Initialize the system."""
        response = api.request_syncmodule(self.blink,
                                          self.network_id,
                                          force=True)
        try:
            self.summary = response['syncmodule']
            self.network_id = self.summary['network_id']
        except (TypeError, KeyError):
            _LOGGER.error(("Could not retrieve sync module information "
                           "with response: %s"),
                          response,
                          exc_info=True)
            return False

        try:
            self.sync_id = self.summary['id']
            self.serial = self.summary['serial']
            self.status = self.summary['status']
        except KeyError:
            _LOGGER.error("Could not extract some sync module info: %s",
                          response,
                          exc_info=True)

        self.network_info = api.request_network_status(self.blink,
                                                       self.network_id)

        self.check_new_videos()
        try:
            for camera_config in self.camera_list:
                if 'name' not in camera_config:
                    break
                name = camera_config['name']
                self.cameras[name] = BlinkCamera(self)
                self.motion[name] = False
                camera_info = self.get_camera_info(camera_config['id'])
                self.cameras[name].update(camera_info,
                                          force_cache=True,
                                          force=True)
        except KeyError:
            _LOGGER.error("Could not create cameras instances for %s",
                          self.name,
                          exc_info=True)
            return False

        return True