Outlook Calendar Integration

Hello community.

Been wanting/needing an Outlook Calendar integration for a while, and over christmas I finally got round to it. I know christmas was a while ago and sorry for the late post.

The component can be found at https://github.com/BottlecapDave/HomeAssistant-OutlookCalendar and is heavily based on the Google Calendar intergration that is included in Home Assistant and the Microsoft To Do integration for authenticating.

I hope to get back to it at some point and expose the confiruation of the integration through the UI at some point in the future. I hope it manages to help someone else in the commuity.

4 Likes

I know this is an older topic, but it looks a nice way to deal with this. Problem I have is with the authorisation. I’ve created the API with localhost, then when I press the notification (after server restart) it tries to connect using the IP of the server. When I alter this to localhost (same as I registered with) it works.
But then it tries to connect back again and I get the page not found. Changed it back to the ip address of HA and then I get 500 Internal Server Error: Server got itself in trouble.

Any idea how to fix this?

Hi. Sorry to hear you’re having issues. I think there might be something missing from the instructions, and that’s setting base_url.

Set the following in your configuration.yaml and then follow the instruction for authenticating.

http:
  base_url: localhost:8123

I think this has been deprecated, so I’ll need to update to use something else.

1 Like

Thanks David, this solved the issue for me. Its now activated

Hi @BottlecapDave,

I have tried to get this set up and followed the instructions carefully. When I restart HA and click the link to authorize my account, I always get taken to an error and the following message:

invalid_request: The provided value for the input parameter 'redirect_uri' is not valid. The expected value is a URI which matches a redirect URI registered for this client application.

I have tried with localhost and an external address (*.duckdns.org) as the redirect URI but no joy.

Any suggestions that could help?

Thanks!

Will

@BottlecapDave I have the same problem. Please help

invalid_request: The provided value for the input parameter redirect_uri is not valid. The expected value is a URI which matches a redirect URI registered for this client application.

Hi @wolfhond and @varyamereon! Sorry for the very late reply.

My home assistant instance is local only, and therefore haven’t tried an external url.

I assume the error message you’re receiving is when clicking the link from home assistant to go to Microsoft for setting up your account?

I’ll try and take a look over the weekend, but I assume the redirectUrl in the link to Microsoft is not quite matching what has been setup in Azure.

Hello

I found a solution on https://github.com/PTST/O365-HomeAssistant

There you can link It manually.

I’m guessing it was the lack of or misconfigured base_url?

Was this your problem as well @varyamereon?

I’m going to try and do an update soon to use the new fields as base_url is marked as deprecated.

Hi

@wolfhond I took a look at the github link but not really sure what the solution was for you, could you point me in the right direction?

@BottlecapDave I don’t have anything set as the base_url, as you say I think it is deprecated.

Will

@varyamereon

Alt auth flow.

NB. This requires the alt_auth_flow to be set to True and the redirect uri in your Azure app set to “https://login.microsoftonline.com/common/oauth2/nativeclient” this needs to be set as as a manual url, with type web, just checking the checkmark for it does not seem to work
After setting up configuration.yaml with the key set to True and restarting home assistant a persisten notification will be created.

  1. Click on this notification.
  2. Click the “Link O365 account” link.
  3. Login on the microsoft page.
  4. Copy the url from the browser url bar.
  5. Insert into the “Returned Url” field. and click Submit.
  6. That’s it.

@wolfhond where are you setting the alt_auth_flow to true?

Just add it in the configuration.yaml

o365:
client_secret: !secret outlook_client_secret
client_id: !secret outlook_client_id
alt_auth_flow: true
email_sensor:

Ah perfect, that worked for me too! Thanks!

Hello, I am running into an issue. Forgive me if it’s something simple, I’m only 3 days into learning Home Assistant, but am very eager to learn more.

I’ve got O365 installed through HACS. My configuration.yaml looks like this:

o365:
  client_secret: !secret o365_secret
  client_id: "e713eccc-164b-44a8-916e-f9f0dc188392"
  alt_auth_flow: true

I created a o365_calendar.yaml file that looks like this:

- cal_id: xxxx
  entities:
  - device_id: work_calendar
    end_offset: 24
    name: Jon's work calendar
    start_offset: 0
    track: true

Where can I find my O365 Calendar ID? I am on a macOS and do not have access to Outlook for Windows, only the web, iOS & macOS apps.

Also, when I click Link O365 account I am sent to a blank screen.

I’m having the same results, did you get this corrected?

I make it as far as Step 3, log in to my account, but then get a blank screen. I don’t seen any URL to copy and insert as in step 4 and 5.

Try a private session in your browser.

1 Like

I tried a private, incognito browser session. Same thing, just get a blank screen.

Shortly checked some topics on ms dev site. You should be able to do it over powershell as every O365 ex task.

Sorry updated version…:wink: had to test it and grabbed my notebook shortly. The way over powershell is to hard an will not as easy as thought.

But there exist and other easy way, just use microsoft graph. You need to have the propper permissions a least to the calendar you request the id from. If you are working on a tenant which is locked down then you need the right to consent permissions by yourself or start the request to an admin.

Open the following link and sign in with your o365 credentials.
https://developer.microsoft.com/en-us/graph/graph-explorer/preview

As get query use the following
https://graph.microsoft.com/v1.0/me/calendar

If not prompted already on the "modify permissions (preview) you can give the necessary consents.

After hitting run on the query you should get the following output below.

Here is the description of the graph api, if you have enough rights you can even get the id’s for someone else or group calendars.

This should give you the needed id from the outlook calendar without outlook. Just building up my home assistant installation so not already there to implement o365 but it’s also a plan to do so.

Hope this helps for you!

2 Likes