Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Remote calendar integration #138862

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

Thomas55555
Copy link
Contributor

@Thomas55555 Thomas55555 commented Feb 19, 2025

Breaking change

Proposed change

Add a remote calendar integration. It allows to add a read-only calendar in ics format. Like suggested here.
It's basically a copy of the local calendar and the write parts are removed. I also added a DataUpdateCoordinator and removed the local storage, so that the data comes from the source directly.
image
image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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:

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 running python3 -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.

To help with the load of incoming pull requests:

@Thomas55555 Thomas55555 marked this pull request as ready for review February 20, 2025 21:47
@Thomas55555 Thomas55555 requested a review from a team as a code owner February 20, 2025 21:47
Copy link
Contributor

@allenporter allenporter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome contribution! This is requested quite a bit so I know folks will definitely like this. 👍🏼 Very good direction, and i just took an initial pass to get the review started (didn't review the tests in detail yet)

_LOGGER = logging.getLogger(__name__)

STEP_USER_DATA_SCHEMA = vol.Schema(
{vol.Required(CONF_CALENDAR_NAME): str, vol.Required(CONF_URL): str}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this isn't done automatically by formatting, this style key/value is easier to read for a schema:

Suggested change
{vol.Required(CONF_CALENDAR_NAME): str, vol.Required(CONF_URL): str}
{
vol.Required(CONF_CALENDAR_NAME): str,
vol.Required(CONF_URL): str
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff is changing it back all the time

IcsCalendarStream.calendar_from_ics, res.text
)
except CalendarParseError as err:
errors["base"] = "no_calendar_found"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use invalid_ics_file consistent with the local calendar upload flow?

Also the feedback on local calendar through some bug reports is that the error is not that helpful yet (e.g. it just fails without any details, but we can fix that in the future)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, would it be okay, to import
"[%key:component::local_calendar::config::error::invalid_ics_file%]"
Or is this a dependency we don't want?

if user_input is not None:
headers: dict = {}
try:
res = await client.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like aiohttp has more adoption within native home assistant code (though httpx is used of course when used by downstream client libraries). Would it be reasonable to use aiohttp here? (I don't know if there is a formal rule on this, just stating what i've observed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, this could also work. I just copied it from the other PR.
I'm actually more concerned about his rule:
https://developers.home-assistant.io/docs/api_lib_index?_highlight=library
Which says to create a library. But that wouldn't make much sense in my opinion, because we just download the file and handle some exceptions.

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft February 24, 2025 15:29
@Thomas55555
Copy link
Contributor Author

Awesome contribution! This is requested quite a bit so I know folks will definitely like this. 👍🏼 Very good direction, and i just took an initial pass to get the review started (didn't review the tests in detail yet)

Thanks. Tests aren't complete anyway. I just started, with the basics. During the review there are a lot of changes anyway. So it's not really worth to test everything in the beginning.

@Thomas55555 Thomas55555 marked this pull request as ready for review February 24, 2025 19:16
@home-assistant home-assistant bot requested a review from allenporter February 24, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants