Skip to content

Limit Whirlpool timestamp changes to +/- 60 seconds#85368

Merged
elupus merged 2 commits into
home-assistant:devfrom
mkmer:Limit_timestamp_update
Jan 8, 2023
Merged

Limit Whirlpool timestamp changes to +/- 60 seconds#85368
elupus merged 2 commits into
home-assistant:devfrom
mkmer:Limit_timestamp_update

Conversation

@mkmer
Copy link
Copy Markdown
Contributor

@mkmer mkmer commented Jan 7, 2023

Proposed change

Limit timestamp changes to +/- 60 seconds: Updating timestamp changes for anything less than 60 seconds produces unnecessary state machine updates with no value to the user. For most cycles this reduces the "changes" by 90%.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

home-assistant Bot commented Jan 7, 2023

Hey there @abmantis, mind taking a look at this pull request as it has been labeled with an integration (whirlpool) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of whirlpool can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign whirlpool Removes the current integration label and assignees on the issue, add the integration domain after the command.

@MartinHjelmare MartinHjelmare changed the title Whirlpool: Limit timestamp changes to +/- 60 seconds Limit Whirlpool timestamp changes to +/- 60 seconds Jan 7, 2023
@elupus
Copy link
Copy Markdown
Contributor

elupus commented Jan 7, 2023

It looks like something was missed in reviews here. State is not supposed to contain things like remaining time that keeps on changing.

Could you please change this sensor to a completion time instead.

@mkmer
Copy link
Copy Markdown
Contributor Author

mkmer commented Jan 7, 2023

This timer value is marked as end time for the wash/dry cycle, it updates the end time while the cycle is running (it starts with and estimate which gets better as the load runs).
It's almost a direct copy of the rainmachine integration -

class TimeRemainingSensor(RainMachineEntity, RestoreSensor):

I'm afraid I don't understand the request.

@elupus
Copy link
Copy Markdown
Contributor

elupus commented Jan 7, 2023

It should be a timestamp of when the machine ends tte cycle instead of a count down.

@mkmer
Copy link
Copy Markdown
Contributor Author

mkmer commented Jan 7, 2023

It is a timestamp.
We take the (current time + duration) and set a time stamp. The API updates the remaining time (duration) on it's own with a state change message (every 15 to 30 seconds). If the abs(current_time + duration) > 60 seconds, we update the timestamp (once for each time the API reports > 60 seconds).
What this PR addresses is the 15-30 second message which caused updates to the timestamp <60 seconds - this happens multiple times during a wash cycle and really adds no value to the user - typically the UI only shows "in x minutes".

Maybe I'm still missing your point?

@elupus
Copy link
Copy Markdown
Contributor

elupus commented Jan 7, 2023

You were not missing my point. I was miss-reading the code. How accurate is the update? Could 30 seconds diff work, could 20?

Im okey with 60. But if we dont need yo be that course it could.be worth being more accurate.

):
"""Test the sensor value callbacks."""
hass.state = CoreState.not_running
thetimestamp: datetime = datetime(2022, 11, 29, 00, 00, 00, 00, timezone.utc)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I fail to understand how the added tests verify the 60 second limits on update? Or are they not doing that?

@mkmer
Copy link
Copy Markdown
Contributor Author

mkmer commented Jan 7, 2023 via email

@mkmer
Copy link
Copy Markdown
Contributor Author

mkmer commented Jan 7, 2023 via email

Copy link
Copy Markdown
Contributor

@elupus elupus left a comment

Choose a reason for hiding this comment

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

Ok for me. A test would be good. I will not merge right away if you want to add a test.

@mkmer
Copy link
Copy Markdown
Contributor Author

mkmer commented Jan 8, 2023

Added tests. Plan to stick with 60 second threshold as it has the minimum number of updates to HA state machine (only a couple per wash/dry cycle) while continuing to provide similar completion times as the Whirlpool app.

@elupus elupus merged commit 45eb1ef into home-assistant:dev Jan 8, 2023
@mkmer mkmer deleted the Limit_timestamp_update branch January 8, 2023 17:58
shbatm pushed a commit to shbatm/home-assistant-core that referenced this pull request Jan 9, 2023
…5368)

* Limit timestamp changes to +/- 60 seconds

* Add timestamp callback tests
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants