OneDrive
This integration allows you to use Microsoft OneDrive
Backups will be created in a folder called Home Assistant\backups_<id>
in the App Folder
of your OneDrive by default.
id
is part of your Home Assistant instance’s unique id to allow backups from multiple instances to the same OneDrive account.
The integration only has access to an application specific Home Assistant
folder in the App Folder
and cannot access any other parts of your OneDrive.
Because of an issue in Microsoft’s APIs, the application-specific folder is often called Graph
instead of Home Assistant
. More on that below.
配置
要将 OneDrive service 添加到您的 Home Assistant 实例中,请使用此 My 按钮:
手动配置步骤
如果上述 My 按钮不起作用,您也可以手动执行以下步骤:
-
浏览到您的 Home Assistant 实例。
-
转到
设置 > 设备与服务。 -
在右下角,选择
Add Integration 按钮。 -
从列表中选择 OneDrive。
-
按照屏幕上的说明完成设置。
Application ID of the app registration to be used with the integration. Uses Home Assistant provided by default.
The name of the instance specific backup folder.
选项
OneDrive 的选项可以通过用户界面设置,具体步骤如下:
- 浏览到您的 Home Assistant 实例。
- 转到 设置 > 设备与服务。
- 如果配置了多个 OneDrive 实例,请选择您想配置的实例。
- 选择集成,然后选择 配置。
Backup folder
The backup folder is root:\Apps\[Home Assistant | Graph]\backups_{id}
. This is not configurable because otherwise the integration would need permissions to write into your entire drive. You can, however, rename the application folder which is called Home Assistant
or Graph
in your OneDrive.
The last folder in the hierarchy (backups_{id}
) is always a unique folder per Home Assistant instance to ensure that backups from different instances are not mixed. The name of this folder can be set during integration setup and can be changed later through reconfiguring the integration or by renaming the folder in OneDrive.
Backup folder is called Graph
This integration uses Microsoft’s Graph API to communicate with your OneDrive. Because of an issueHome Assistant
), but Graph
instead.
There is no risk of different applications mixing in that Graph
folder, if you already have such a Graph
folder from a different application, the next folders will just be called Graph 1
, Graph 2
and so on.
You should be able to manually rename the folder to something else, without the integration breaking.
Requested permissions by the integration
The integration will request the following permissions on your OneDrive for the integration to work:
-
Files.ReadWrite.AppFolder
: Grants the application permission to read and write in its own, app-specific folder inside your OneDrive -
offline_access
: Grants the application permission to refresh its authentication token without requiring your manual intervention -
openid
: Grants the application permission to read basic information, e.g. if you have a OneDrive

Sensors
The integration provides the following sensors, which are updated every 5 minutes:
- Total available storage: The total size of your drive (disabled by default)
- Used storage: The amount of storage you have used up
- Remaining storage: The amount of storage that is left in your drive
-
Drive state: Calculated state of your drive, based on the storage left. Possible values:
Normal
,Nearing limit
,Critical
,Exceeded
A drive that is in Drive state Exceeded
will be automatically frozen (meaning you can’t upload any more backups & files), until you clear up enough storage.
Automations
Get started with these automation examples.
Send alert when drive is near storage limit
Send an alert when the drive usage is close to the storage limit and needs cleanup.
Example YAML configuration
alias: Alert when OneDrive is close to storage limit
description: Send notification to phone when drive needs cleanup.
triggers:
- trigger: state
entity_id:
- sensor.my_drive_drive_state
from: "normal"
to: "nearing"
- trigger: state
entity_id:
- sensor.my_drive_drive_state
from: "nearing"
to: "critical"
actions:
- action: notify.mobile_app_iphone
data:
title: OneDrive is almost full!
message: >
OneDrive has used up {{ states('sensor.my_drive_used_storage') }} of {{
states('sensor.my_drive_total_available') }}GB. Only {{ states('sensor.my_drive_remaining_storage') }}GB remaining.
mode: single
Getting application credentials
This integration comes with a predefined set of application credentials through Home Assistant account linking. This means you should not need to provide credentials, but get redirected to Microsoft’s sign-in page.
Even if you use the default credentials, nobody will ever have access to your data except you, as the app does not have permission to do anything on its own. It only works with a signed-in user (it only has delegated
not application permissions
).
However, if you want to use your own credentials, follow this guide
You will need an Azure tenant with an active Azure subscription to create your own client credentials.
Make sure to configure the following settings on the app registration:
- Supported account types: Personal Microsoft accounts only
-
Redirect URI: Type:
Web
, URL:https://my.home-assistant.io/redirect/oauth

If you set the integration up with the default credentials and switch to custom credentials later, your backup folder will change inside your OneDrive, and you will have to manually copy existing backups from the old folder to the new one.
Known limitations
- Only personal OneDrives are supported at the moment.
Removing the integration
This integration follows standard integration removal. No extra steps are required.
从Home Assistant中移除集成实例
- 前往 设置 > 设备与服务 并选择集成卡片。
- 从设备列表中,选择要删除的集成实例。
- 在条目旁边,选择三个点
菜单。然后,选择 删除。
Troubleshooting
Unknown error while adding the integration
Make sure that your OneDrive is not frozen. This can happen if you haven’t used it for a longer period of time, or went over your data quota.
Default credentials not available
If the integration asks you for a client ID
and a client secret
, that likely means you disabled part of the default_config
in your Home Assistant configuration. For account linking to work you’ll need my
& cloud
integrations loaded.