sdaoudi / HomeAssistant-GDrive-Uploader

Goole Drive Uploader component for Home Assistant
3 stars 0 forks source link
google-drive google-drive-uploader hassio hassio-integration home-assistant homeassistant

GDrive Uploader

HACS Validation hassfest Validation hacs_badge

GDrive Uploader is a Home Assistant integration that offers service to upload files to Google Drive.

Installation

Method 1. HACS custom repo:

HACS > Integrations > 3 dots (upper top corner) > Custom repositories > URL: sdaoudi/HomeAssistant-GDrive-Uploader, Category: Integration > Add > wait > GDrive Uploader > Install

Method 2. Manually copy gdrive_uploader folder from latest release to /config/custom_components folder.

Configuration

In your configuration.yaml, include:

gdrive_uploader:
  credentials_file_path: "/config/secrets/credentials.json"

The credentials_file_path is the path to your credentials.json file generated with your client_id and client_secret (You can follow this documentation to create your own credentials.json file).

Usage

Upload file

New service gdrive_uploader.upload:

script:
  upload_video:
    alias: Upload video
    sequence:
      - action: gdrive_uploader.upload
        data:
          parent_id: 20YTAZESppoiZ4hvuI543diltpez53tSt # Google Drive folder ID
          upload_file_path: /config/home-assistant.log # Path of file to upload

You can specify a target_dir_name, which allows you to create a new directory within the parent directory, and it is this new directory where your file will be uploaded:

script:
  upload_video:
    alias: Upload video
    sequence:
      - action: gdrive_uploader.upload
        data:
          parent_id: 20YTAZESppoiZ4hvuI543diltpez53tSt
          target_dir_name: "my_videos"
          upload_file_path: /config/home-assistant.log

By default, if the file is already exist in the target directory, it will be not uploaded. You can force the upload by setting override_file to true:

script:
  upload_video:
    alias: Upload video
    sequence:
      - action: gdrive_uploader.upload
        data:
          parent_id: 20YTAZESppoiZ4hvuI543diltpez53tSt
          upload_file_path: /config/home-assistant.log
          override_file: true

Delete file or directory

New service gdrive_uploader.delete:

script:
  delete_video:
    alias: Delete video
    sequence:
      - action: gdrive_uploader.delete
        data:
          parent_id: 20YTAZESppoiZ4hvuI543diltpez53tSt # Google Drive folder ID
          dir_name: my_dir_to_remove # The directory name in Google Drive