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

fix: Setup of integration with generic ICS fails since HA 2025.1 #3421

Closed
wants to merge 2 commits into from

Conversation

z-master42
Copy link

In my opinion, removes unused and legacy code that prevents the integration from being set up since HA 2025.1 when using a generic ICS file or URL.

See #3259, #3271, #3390, #3397, #3409

@affeldt28
Copy link
Contributor

Why not delete the ICS_v1.py like you mentioned in your comment?

@z-master42
Copy link
Author

Yes, you can do this, but it is not really necessary as it is not integrated anywhere and therefore the code is not used.

@schmidtfx
Copy link

It is a backwards incompatible fix, is there anyway to set version=1?

@z-master42
Copy link
Author

As far as I can read the code, version == 2 is hardcoded.

@ChristophCaina
Copy link
Contributor

I can confirm that this pr has fixed the issue #3271 which I have reported.

Thanks :)

@TDCroPower

This comment was marked as resolved.

@z-master42

This comment was marked as resolved.

@@ -141,7 +140,6 @@ def __init__(
regex: str | None = None,
title_template: str = "{{date.summary}}",
split_at: str | None = None,
version: int = 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This breaks existing installations. Just keep the argument

Copy link
Author

Choose a reason for hiding this comment

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

At what point? "version" is no longer used within the class. This is exactly how it works for me (with an ICS file an some test URL).

Choose a reason for hiding this comment

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

attention: I don't know much about python and even less about this code base. But to me it looks like version: int = 2 just declares the default value as version 2. For my limited understanding, the ics datasource configuration can configure version: 1. Shown in the "test comments" above for example.

By that, my assumption is that there might be installations out there, that require this code for backwards (version) compatibility. In this class the parameter might not be used any more, but the configuration of these instances seems pretty dynamic.

So, this might be a hack/fix to make it work locally. But probably not a general fix for the problem. But again, not knowing much about this particular code here, just having the same problem with my installation.

Copy link
Author

Choose a reason for hiding this comment

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

The version can only be selected if WCS is configured via YAML. When using the UI, which is the preferred and default way, it is always version 2. The version only determines which parser is used.

version
(integer) (optional, default: 2)

Selects the underlying ICS file parser:

version: 1 uses recurring_ical_events
version: 2 uses icalevents

For more see configuration via YAML: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc%2Fsource%2Fics.md

Copy link
Collaborator

@5ila5 5ila5 Jan 7, 2025

Choose a reason for hiding this comment

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

removing this argument breaks every existing configuration using the ics source as the integration tries to set up the source with an argument not accepted by the __init__

The version arguemnt is registered in every ics source configuration. Additionally it can be set in the GUI it just defaults to 2 but you CAN change it:

image

Copy link
Author

Choose a reason for hiding this comment

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

Ahh, at the bottom 😉. But it's just the choice of which parser to use and not a compatibility story. If someone uses version 1, it won't work anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would still be a problem when removing it from the __init__ as it would throw TypeError: Source.__init__() got an unexpected keyword argument 'version' when setting starting with an existing configuration having the version attribute to anything.

@5ila5

This comment was marked as resolved.

@TDCroPower

This comment was marked as resolved.

@5ila5

This comment was marked as resolved.

@TDCroPower

This comment was marked as resolved.

@5ila5

This comment was marked as resolved.

@TDCroPower

This comment was marked as resolved.

@z-master42

This comment was marked as resolved.

@TDCroPower

This comment was marked as resolved.

@z-master42
Copy link
Author

Here you can see how the implementation was carried out three years ago. ICS_v1.py is the swap of a previous version that has not been used since then.

5ad421b

@aseith

This comment was marked as resolved.

@BoGnY

This comment was marked as duplicate.

@z-master42

This comment was marked as resolved.

@TDCroPower

This comment was marked as resolved.

@z-master42
Copy link
Author

https://www.w3schools.com/python/python_conditions.asp 😉

@5ila5
Copy link
Collaborator

5ila5 commented Jan 7, 2025

Just to clarify:

Version is NOT hard coded, it is just a default value.

I opened a PR (#3468) doing what I said above and writing a migration to remove the version argument from the GUI configurations. YAML configuration still using the version argument will see a warning in their logs.

I will merge #3468 if no one finds an issue with that

@Vato9394
Copy link

Vato9394 commented Jan 7, 2025

This fix fixed it for me:
https://www.youtube.com/watch?v=yhxbTMrojH0

@z-master42
Copy link
Author

z-master42 commented Jan 7, 2025

Just to clarify:

Version is NOT hard coded, it is just a default value.

I opened a PR (#3468) doing what I said above and writing a migration to remove the version argument from the GUI configurations. YAML configuration still using the version argument will see a warning in their logs.

I will merge #3468 if no one finds an issue with that

I see it. Thank you!

@z-master42
Copy link
Author

So can we close this PR here?

@5ila5 5ila5 closed this in #3468 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.