camera package
Submodules
camera.camera
- class camera.camera.Camera(config: Configuration, loop, camera_task_queue_async: Queue, message_task_queue: Queue)
Bases:
object
- async add_2fa_blink_token(task: Camera_Task) bool
Adds a required 2FA token to blink session.
- Parameters:
self (object): The instance of the class. task (Camera_Task): The task containing the 2FA token information.
- Returns:
bool: True if the token is successfully added.
- adjust_image() bool
Adjusts brightness and contrast of the stored photo based on the configuration values.
- Returns:
bool: True if adjustment was successful, False on errors
- async blink_snapshot() bool
Asynchronously takes a snapshot from a Blink camera and saves it to a specified file path. If detect_daylight is night and when image_brightning is enabled, the image will be adjusted.
- Returns:
bool: True if the snapshot was successfully taken and saved, False otherwise.
- async choose_cam(task: Camera_Task)
Asynchronously chooses a camera based on various conditions such as daylight detection, night vision, and default camera type. Decision is: - daylight detection enabled:
daylight takes default_camera_type
night: takes night vision enabled cam, if two precedence is blink over picam
- daylight detection disabled:
takes default_camera_type
- Args:
self: The Camera object. task (Camera_Task): The task containing information for camera selection.
- Returns:
The result of the camera selection process.
- detect_daylight() bool
Detects whether it is currently daylight based on sunrise and sunset times.
The method uses either the configured coordinates (latitude and longitude) or the configured country to calculate sun times.
- Returns:
- bool: True if it is daylight (between sunrise and sunset),
False if it is dark Incase of error True is returned as daylight
- picam_request_download_foto() bool
Downloads a photo from the PiCam REST-API.
This function sends a GET request to the PiCam API to download a photo. The photo is saved to the file specified in the photo_image_path configuration. If detect_daylight night and when image_brightning is enabled, the image will be adjusted.
- Returns:
bool: True if the HTTP request status code is 200, otherwise False.
- picam_request_take_foto() bool
A function to request taking a photo using PiCam, sending a POST request with specific parameters, and logging the process.
- Returns:
True if the HTTP request status code is 200, otherwise False
- Return type:
bool
- put_msg_queue_error(task: Camera_Task, message: str)
Puts a message queue error based on the provided task and message.
- Args:
task (Camera_Task): The task to be processed. message (str): The error message to be added to the queue.
- Returns:
None
- put_msg_queue_photo(task: Camera_Task)
Puts a message queue photo based on the provided task.
- Args:
task (Camera_Task): The task to be processed.
- Returns:
None
- async read_blink_config()
Asynchronously reads the Blink configuration file and authenticates with Blink.
This function checks if the Blink configuration file exists. If it does, it loads the configuration file using the json_load function, creates an Auth object with the loaded configuration, sets the auth attribute of the blink object to the created Auth object, logs a message indicating that the authentication was done using the file, and sets the authentication_success variable to True.
If the Blink configuration file does not exist, it logs a message indicating that the file was not found and that a 2FA authentication token is required. It creates an Auth object with the provided Blink username and password, sets the auth attribute of the blink object to the created Auth object, and sets the authentication_success variable to None.
- Parameters:
self (object): The instance of the class.
- Returns:
None
- async save_blink_config() bool
Saves the authenticated session information of the Blink service into a config file.
This function saves the authenticated session information of the Blink service into a config file. It logs a message indicating that the session information is being saved. Then it calls the save method of the blink object, passing the blink_config_file attribute of the config object as the file path.
- Parameters:
self (object): The instance of the class.
- Returns:
bool: True if the session information is successfully saved.
- async start() None
Initializes the camera, starts a blink session if enabled, and processes various camera tasks asynchronously.