RogerSelwyn / O365-HomeAssistant

Office 365 integration for Home Assistant
MIT License
195 stars 15 forks source link

Can't add birthday events to calendar #219

Closed Breakingx closed 5 months ago

Breakingx commented 5 months ago

Hey,

after adding my calendars to HA I tried to delete/edit/create some birthday entries.

My API Permissions are: image

In the event view I receive the Error "Unknown error"

The Log states this:

`Logger: homeassistant.components.websocket_api.http.connection Quelle: custom_components/o365/calendar.py:370 Integration: Home Assistant WebSocket API (Dokumentation, Probleme) Erstmals aufgetreten: 11:53:22 (2 Vorkommnisse) Zuletzt protokolliert: 12:11:12

[140667804533696] Error handling message: Unknown error (unknown_error) XY from 195.145.227.84 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0) [140667425491392] Error handling message: Unknown error (unknown_error) XY from 195.145.227.84 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/calendar/init.py", line 731, in handle_calendar_event_create await entity.async_create_event(*msg[CONF_EVENT]) File "/config/custom_components/o365/calendar.py", line 316, in async_create_event await self.async_create_calendar_event( File "/config/custom_components/o365/calendar.py", line 370, in async_create_calendar_event await self.hass.async_add_executor_job(event.save) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/calendar.py", line 1471, in save response = method(url, data=data) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 909, in post return self.oauth_request(url, 'post', data=data, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 887, in oauth_request return self._internal_request(self.session, url, method, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/O365/connection.py", line 848, in _internal_request raise HTTPError('{} | Error Message: {}'.format(e.args[0], error_message), requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/calendars/{token}/events | Error Message: Your request can't be completed. Read-only calendars can't be modified. `

RogerSelwyn commented 5 months ago

Since you specify them as 'birthday events' my guess its that you are trying to add to specific birthday calendar? By the look of that, it would also need permissions to add contacts, since it looks like a birthday calendar is driven from your contact list.

That said I wouldn't be sure that you could even add an event to the Birthday Calendar via the MS Graph api, the natural thing to do would be to add the info to the relevant contact such that it would populate the birthday calendar.

Breakingx commented 5 months ago

You are completly right. After adding a birthday to a contact it was instantly synced to the O365 birthday calendar in HA.

Thanks!