core
core copied to clipboard
Add GoogleCalendarEvent class with "attendees" attribute
Proposed change
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [x] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
- This PR fixes or closes issue: fixes #
- https://community.home-assistant.io/t/google-calendar-invitation-acceptance-status-as-attribute/429269
- Link to documentation pull request:
- [ ] Update https://www.home-assistant.io/integrations/google/
Google Calendar API doc
Checklist
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. Your PR cannot be merged unless tests pass
- [ ] There is no commented out code in this PR.
- [ ] I have followed the development checklist
- [ ] I have followed the perfect PR recommendations
- [ ] The code has been formatted using Ruff (
ruff format homeassistant tests) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to
.coveragerc.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @allenporter, mind taking a look at this pull request as it has been labeled with an integration (google) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of google can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign googleRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (calendar) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of calendar can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign calendarRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Still WIP, will add the attendees_omitted related logic and unit tests later
@allenporter Thanks for your input.
Here we go https://github.com/home-assistant/architecture/discussions/1099
Hey @allenporter I am getting back on this (after our discussion here) and making good progress.
Highlight of the new approach:
- Introduce a new class
GoogleCalendarEvent(extend fromCalendarEvent) and addattendeesattribute there only. This is to control the blast radius and not to worry about other integration use cases just yet. - Modify the
_event_filtermethod to return events that are (both)- Opaque (show as busy)
- Accepted by self
I was able to test the changes locally with a few caveats:
- The logic to filter events that are
accepted by selfneeds some love as I wasn't able to figure out where to get the email for self. - From my local testing, the returned attendees data seem to be corrupted where
display_nameandresponse_statusalways returns the default value, regardless of the actual value.
Example (real data with redacted email)
attendees=[Attendee(id=None, email='redacted', display_name=None, optional=False, comment=None, response_status=<ResponseStatus.NEEDS_ACTION: 'needsAction'>), Attendee(id=None, email='redacted', display_name=None, optional=False, comment=None, response_status=<ResponseStatus.NEEDS_ACTION: 'needsAction'>)]
Digging around, I think the issue might be due to the slight nuance of the alias feature in pydantic v1 and v2. (apparently home assistant is using v1 whereas gcal_sync supports both v1 and v2)
3. The attendees[].self boolean field might be useful to solve point 1 but it was removed by the _remove_self validator. Can I suggest we keep this and rename it to say is_self?
Gentle bump
Ah sorry you can mark "Ready for review" when its ready, otherwise its still in draft. I'll take a look.
sorry didn't realize that was a question above.
I think an upstream to fix attendees[].self looks like it may be the way to go. This may need a fix in gcal_sync to store it with some other field name since self has special meaning in python and pydantic is hiding it.
I don't think you need to add GoogleCalendarEvent given that the filtering is happening on the gcal_sync Event type.
@allenporter
Thanks for your review on the attendees[].self and GoogleCalendarEvent. However the whole flow still doesn't work because attendees[].response_status is essentially broken due to the broken alias I mentioned above. Do you have any recommendation to fix this? I am still pretty new to pydantic so any pointer is welcome.
I have created an issue in https://github.com/allenporter/gcal_sync/issues/545
I don't think you need to add GoogleCalendarEvent given that the filtering is happening on the gcal_sync Event type.
But I only want google calendar event to have the attendees attribute (i.e. not other local calendar or todoist)
I don't think you need to add GoogleCalendarEvent given that the filtering is happening on the gcal_sync Event type.
But I only want google calendar event to have the
attendeesattribute (i.e. not other local calendar or todoist)
The filter function uses gcal_sync.model.Event not the calendar platform.
I don't think you need to add GoogleCalendarEvent given that the filtering is happening on the gcal_sync Event type.
But I only want google calendar event to have the
attendeesattribute (i.e. not other local calendar or todoist)The filter function uses
gcal_sync.model.Eventnot the calendar platform.
Right, we don't need to store the attribute, just use it for filtering.
Marking this PR draft, awaiting the results of the architectural discussion.
../Frenck
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes. Thank you for your contribution!