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

Update TimeSMAFilter based on time #53053

Closed
wants to merge 2 commits into from
Closed

Update TimeSMAFilter based on time #53053

wants to merge 2 commits into from

Conversation

Danielhiversen
Copy link
Member

@Danielhiversen Danielhiversen commented Jul 15, 2021

Signed-off-by: Daniel Hjelseth Høyer [email protected]

Breaking change

Proposed change

Update TimeSMAFilter based on time
A time-based filter should not only update when the source value is updated.
Make a new configuration to allow this.
Needs to update documentation and add a test.

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)
  • 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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>
@@ -454,7 +462,7 @@ def filter_state(self, new_state):


@FILTERS.register(FILTER_NAME_RANGE)
class RangeFilter(Filter, SensorEntity):
class RangeFilter(Filter):
Copy link
Member Author

Choose a reason for hiding this comment

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

I might have misunderstood something, but I see no reason for the filters to inherit SensorEntity

Copy link
Contributor

Choose a reason for hiding this comment

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

Not that I can recall :/

since tests didn't break and coverage is high, I'm ok with this

@probot-home-assistant
Copy link

Hey there @dgomes, mind taking a look at this pull request as its been labeled with an integration (filter) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@dgomes
Copy link
Contributor

dgomes commented Jul 15, 2021

This idea was discussed in the past (unfortunately can't find original discussion)

As I recall the issue put forward was that this would create fake states. Since no update from the source sensor triggers the new filter state, the filter sensor can produce completely unrelated values to the source.

@dgomes
Copy link
Contributor

dgomes commented Jul 15, 2021

@Danielhiversen
Copy link
Member Author

Danielhiversen commented Jul 15, 2021

I see your point.
In my opinion, it would still be better to show correct results.

An example where the source sensor is low for a long period, then a constant high value for a period. Then the filtered value is not updated before the source sensor drops back to the low value.
image
I would have expected the filtered value to increase until it reached the source value if the source value was constant long enough.

If you already have discussed this and concluded that the current behavior is intended, I guess we can close this pr?

@dgomes
Copy link
Contributor

dgomes commented Jul 15, 2021

I think the original PR already discussed this issue:

#13104 (comment)

what I never did, was to submit the SMA_linear

@Danielhiversen
Copy link
Member Author

Hmm, not sure I see any arguments about fake states? Is that the main argument?
@dgomes what is your opinion?

@dgomes
Copy link
Contributor

dgomes commented Jul 15, 2021

Fake states was another discussion, haven't traced yet where that occurred.

Personally I'm fine in creating a configuration option or a new filter with your intended behaviour.

@Danielhiversen
Copy link
Member Author

Personally I'm fine in creating a configuration option or a new filter with your intended behaviour.

Will do that 👍

Signed-off-by: Daniel Hjelseth Høyer <[email protected]>
Copy link
Contributor

@dgomes dgomes left a comment

Choose a reason for hiding this comment

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

Tests need to be updated

@@ -72,6 +73,8 @@
NAME_TEMPLATE = "{} filter"
ICON = "mdi:chart-line-variant"

SCAN_INTERVAL = timedelta(minutes=3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reasoning for choosing 3min ?

@dgomes
Copy link
Contributor

dgomes commented Jul 17, 2021

Also documentation needs to be updated

@github-actions
Copy link

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 16, 2021
@github-actions github-actions bot closed this Aug 23, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2021
@frenck frenck deleted the filter branch March 10, 2022 08:16
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.

3 participants