Custom Component for Home Assistant.
Component to interface with Microsoft's Graph API on your organization's tenant. Currently only detects the authorized user's Microsoft Teams availability and activity but the possibilities are almost endless.
The Microsoft Graph integration allows Home Assistant to create sensors from various properties of your Office 365 tenant via Microsoft's Graph API. All queries are performed using the authenticated user's account and depend on the permissions granted when creating the Azure AD application.
Home Assistant authenticates with Microsoft through OAuth2. Set up your credentials by completing the steps in Manual Configuration and then add the integration in Configuration -> Integrations -> Microsoft Graph. Ensure you log in using a Microsoft account that belongs to your organization's tenant.
- If it doesn't already exist, create a directory called
microsoft_graph
underconfig/custom_components/
. - Copy all files in
custom_components/microsoft_graph
to yourconfig/custom_components/microsoft_graph/
directory. - Restart Home Assistant to pick up the new integration.
- Configure with config below.
You will need to register an application in Azure AD and retrieve the client ID and client secret:
- Register a new application in Azure AD, Click “New Registration”
- URL: https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade
- Name your application
- Select "Accounts in any organizational directory (Any Azure AD directory - Multitenant)" under supported account types
- Ignore Redirect URI (for now), click “Register”
- You will now be on the “Overview” page for your app, copy the “Application (client) ID” value and save it for later
- In the left menu, select “Authentication”
- Click “Add a platform”
- Select “Web”
- Add https://<EXTERNAL_HOME_ASSISTANT_URL>:PORT/auth/external/callback
- Click the “Configure” button
- Still In the Authentications Tab, select “Add URI”
- Paste in https://my.home-assistant.io/redirect/oauth
- Scroll down and ticket “Access tokens” and “ID Tokens” check boxes
- Scroll down further, select the “Accounts in any organizational directory (Any Azure AD directory - Multitenant)” radio button
- Click the “Save” button
- In the left menu, select “Certificates & secrets”
- Click “New client secret”
- Set a description and expiration date (max 24 months), click the “add” button
- You will now be presented a ‘value’ and ‘secret ID’. Copy the "value" field and save it for later
- In the left menu, select “API Permissions”
- Click “Add a Permission”
- Select “Microsoft Graph”
- Select “Delegated Permissions”
- Search for Presence.Read, expand “Presence” and select “Presence.Read”
- Search for User.Read, expand “User” and select “User.Read”
- Click the “Add permissions” button
- You are done with Azure
- Go to settings > Devices & services > Add Integration > Microsoft Graph
- Input your ClientID and Secret Value from earlier, click “next”
- A new tab will open with “Link account to Home Assistant?”, Click “Link account”
The Microsoft Graph sensor platform automatically tracks various resources from your Office 365 tenant.
There are 2 sensors that are added, both of which are enabled by default.
Entity ID | Default | Description |
---|---|---|
sensor.ms_teams_availability |
Enabled | Shows your availability (e.g. Available, AvailableIdle, Away). |
sensor.ms_teams_activity |
Enabled | Shows your activity (e.g. InACall, InAConferenceCall, Inactive, InAMeeting). |
See possible availability and activity values here.