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 for 2024.4 #131

Closed
wants to merge 3 commits into from
Closed

Conversation

Fischelsberger
Copy link

@Fischelsberger Fischelsberger commented Apr 14, 2024

Proposed change

Replacing the old "Forecast" Attribut with a service call of "weather.get_forecasts" so that it's working with 2024.4.
Tested it with Homeassistant 2024.3 and 2024.4, working with booth.

Also fixed an issue wich was within that line.
datetime.utcfromtimestamp(fc_date / 1000)
Some Extension provided by Homeassistant devcontainer or python itself requested that change...

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to an this integration)
  • 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.
  • There is no commented out code in this PR.
  • The code has been formatted using Black (black --fast custom_components)

If user exposed functionality or configuration variables are added/changed:

  • Documentation added/updated to README.md

Copy link

@golles golles left a comment

Choose a reason for hiding this comment

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

LGTM

@Fischelsberger
Copy link
Author

@golles, I've implemented your suggestions, but only tested it with 2024.4 this time.
Also im very new to the git-game, so not sure if "force push" in the old commit was the best choice...

@sudoxnym
Copy link

Implemented your changes. Am now getting binary result. Can't tell if it's working though, is 'Off" Wash or Don't Wash?

@Fischelsberger
Copy link
Author

tbh, i'm 99% sure that it always was binary.
But now as I think about, the "translation" don't make any sense with just binary results?

off = don't wash
on = wash

@sudoxnym
Copy link

It's working. Thank you. I believe it used to say "wash" and "don't_wash". But knowing which is which is good. Apparently it's gonna snow tomorrow, it's sunny today so I was like "why not wash?" Now I know. Thanks for the fix!

Copy link

@golles golles left a comment

Choose a reason for hiding this comment

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

@Fischelsberger thanks for addressing the comment. This looks good and I've also tested it locally and no issues!

I'm not the owner of this repo so I don't know what @Limych would require. Hopefully, he can have a look at this and also approve the usage of the workflows in this PR so we can see if CI passes.

@Fischelsberger
Copy link
Author

Fischelsberger commented Apr 16, 2024

@Fischelsberger thanks for addressing the comment. This looks good and I've also tested it locally and no issues!

I'm not the owner of this repo so I don't know what @Limych would require. Hopefully, he can have a look at this and also approve the usage of the workflows in this PR so we can see if CI passes.

@golles Wait, is this fixing your #128 then aswell?

@golles
Copy link

golles commented Apr 16, 2024

@Fischelsberger thanks for addressing the comment. This looks good and I've also tested it locally and no issues!
I'm not the owner of this repo so I don't know what @Limych would require. Hopefully, he can have a look at this and also approve the usage of the workflows in this PR so we can see if CI passes.

@golles Wait, is this fixing your #128 then aswell?

Yes indeed, it's basically the same issue

custom_components/car_wash/binary_sensor.py Outdated Show resolved Hide resolved
blocking=True,
return_response=True,
)
forecast = daily_response[self._weather_entity]["forecast"]
Copy link
Owner

Choose a reason for hiding this comment

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

Please add a check for the presence of a result in the return value (daily_response). And also add a unit test for your code.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the review and requested changes.
I've just added a new commit, with the changes which are looking good to me.

Also changed some imports, because ruff suggested these changes.

@Limych Limych marked this pull request as draft April 18, 2024 10:35
@Fischelsberger Fischelsberger requested a review from Limych April 18, 2024 19:55
Copy link
Owner

@Limych Limych left a comment

Choose a reason for hiding this comment

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

And please add unit tests to cover code you're made.

)
if not (isinstance(daily_response, dict)):
self._attr_is_on = None
raise HomeAssistantError("daily_response is empty.")
Copy link
Owner

Choose a reason for hiding this comment

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

This error message is not clear to the user if he sees it in the log. The user does not know what daily_response is.

Copy link
Author

Choose a reason for hiding this comment

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

fixed it with new commit, by just using the original message
"Can't get forecast data! Are you sure it's the weather provider?"

by setting forecast = None

Copy link
Owner

Choose a reason for hiding this comment

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

The option is suitable, but it will be better if the error message is more unique, so that it is also more clear to developers about where the failure actually occurred.

custom_components/car_wash/binary_sensor.py Outdated Show resolved Hide resolved
@Fischelsberger
Copy link
Author

Fischelsberger commented Apr 20, 2024

And please add unit tests to cover code you're made.

Sorry @Limych, I don't really understand the whole unit test thing...
It seems to me, with the original devcontainer.json it's no longer working.
Also the Image there https://ghcr.io/ludeeus/devcontainer/integration:stable is Deprecated.

I've tried multiple ways, but I simply can't understand that (right now)...
I'm not a programmer myself, I just wanted to have that thing running again.
If anyone can provide me with some insights or even better, a working unit-test, I will be more then glad to implement it and run these tests and the devcontainer myself.

@Limych
Copy link
Owner

Limych commented Apr 20, 2024

With unit tests everything is quite simple. We take the existing code as a basis, but we need to check all new branches according to the conditions. It is necessary to patch self.hass.services.async_call in the test and return two variants of results - normal and error. And check that the code reacts correctly to each option. Tomorrow I'll try to find some time and write some sample code.

@Limych
Copy link
Owner

Limych commented May 9, 2024

Closed because these changes are no longer necessary due to the release of a new version of the component.

@Limych Limych closed this May 9, 2024
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.

Broken on HA 2024.4.0b0
5 participants