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: Update state with earlier charge complete and arrival times #575

Merged
merged 6 commits into from
May 6, 2023

Conversation

InTheDaylight14
Copy link
Contributor

Added absolute value around the seconds comparison to allow for a state change when the charge complete time and the arrival time move earlier than before.

closes #565

@InTheDaylight14 InTheDaylight14 changed the title Fix: Update state with earlier charge complete and arrival times fix: Update state with earlier charge complete and arrival times Apr 20, 2023
@InTheDaylight14 InTheDaylight14 marked this pull request as draft April 20, 2023 20:12
tests/test_sensor.py Outdated Show resolved Hide resolved
@InTheDaylight14
Copy link
Contributor Author

I've confirmed this change works in home assistant. I'm not sure how to get the state to update in the test after the times move earlier.

@InTheDaylight14
Copy link
Contributor Author

I've confirmed this change works in home assistant. I'm not sure how to get the state to update in the test after the times move earlier.

Such a small logic change I think we are good w/o specific test

@InTheDaylight14 InTheDaylight14 marked this pull request as ready for review April 24, 2023 16:03
@alandtse
Copy link
Owner

My preference is that we have a test to help with regressions. HA should have loads of examples of testing around mocking time. I think they use timemachine but there are alternatives.

@InTheDaylight14
Copy link
Contributor Author

I'm able to mock the time okay. The entity state does not update after the mocked time changes (I tired to increase and decrease the time to make sure, increasing works under the original logic). Is there a way to force HA to update the sensors?

Not working test sequence:

  • Check sensor state: passes
  • Change Tesla API value to arrive 3 minutes earlier than before
  • Set time 2 minutes in future
  • Re-check state: state has not changed from the first check. Should be 1 minute before the first check.

@alandtse
Copy link
Owner

I haven't done HA testing for a while, but again, this is probably something done in core a lot.

@InTheDaylight14
Copy link
Contributor Author

I've dumped way too much time into this, I can't solve it.

I think I've narrowed down to, the mock controller does not grab new data and update the HA states during the test. Its not an issue with the changing time, that would be easy.

@alandtse
Copy link
Owner

alandtse commented May 6, 2023

Well, if you can't solve it just merge up to dev and I'll get you in the next release.

@alandtse alandtse merged commit 92da756 into alandtse:dev May 6, 2023
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.

Arrival time sensor does not update properly
2 participants