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

Suppress log warnings when a sensor group has non numeric members #102828

Merged
merged 8 commits into from Jan 31, 2024
Merged

Suppress log warnings when a sensor group has non numeric members #102828

merged 8 commits into from Jan 31, 2024

Conversation

mill1000
Copy link
Contributor

@mill1000 mill1000 commented Oct 25, 2023

Breaking change

None

Proposed change

Suppress log warnings from sensor groups that have non-numeric members and have been configured to ignore said non-numeric values

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

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (group) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of group can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign group Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@mill1000
Copy link
Contributor Author

Oops looks like there's some test updates I didn't catch.

@MartinHjelmare MartinHjelmare changed the title Suppress log warnings when a sensor group has non numeric members and… Suppress log warnings when a sensor group has non numeric members Oct 26, 2023
@mill1000
Copy link
Contributor Author

I'm guessing the failed code coverage check was just a transient error but I'm unable to restart the job.

Copy link
Contributor

@teharris1 teharris1 left a comment

Choose a reason for hiding this comment

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

Is this a breaking change? Given that the mode parameter has now been redefined as ignore_non_numeric with different logic, is it likely that a template is now assuming the mode logic?

@mill1000
Copy link
Contributor Author

mill1000 commented Jan 16, 2024

Is this a breaking change? Given that the mode parameter has now been redefined as ignore_non_numeric with different logic, ...

Hm...not sure I follow. With regards to the mode parameter the logic is unchanged (except for the log warning).

self.mode = all if mode is False else any

is equivalent to

validate = any if self._ignore_non_numeric else all

... is it likely that a template is now assuming the mode logic?

I don't understand how a template (as in template sensor) comes into play here. Can someone manually create a sensor group inside a template?

@gjohansson-ST gjohansson-ST self-requested a review January 25, 2024 16:23
Copy link
Member

@gjohansson-ST gjohansson-ST left a comment

Choose a reason for hiding this comment

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

Some initial comments

homeassistant/components/group/sensor.py Show resolved Hide resolved
homeassistant/components/group/sensor.py Show resolved Hide resolved
homeassistant/components/group/sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 25, 2024 16:46
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@mill1000 mill1000 marked this pull request as ready for review January 25, 2024 18:16
@mill1000
Copy link
Contributor Author

That CI failure seems to be unrelated to the change

homeassistant/components/group/sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Show resolved Hide resolved
tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 26, 2024 00:23
@mill1000 mill1000 marked this pull request as ready for review January 26, 2024 20:08
Copy link
Member

@gjohansson-ST gjohansson-ST left a comment

Choose a reason for hiding this comment

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

Some minor changes in tests then this should be fine to go 👍

tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
tests/components/group/test_sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 30, 2024 14:31
mill1000 and others added 6 commits January 30, 2024 09:38
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
- Restore `_mode` to original name
- Update test case and group names
- Assert that non numeric doesn't generate any warning in the logs
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
@mill1000 mill1000 marked this pull request as ready for review January 30, 2024 16:49
Copy link
Member

@gjohansson-ST gjohansson-ST left a comment

Choose a reason for hiding this comment

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

Thanks @mill1000 👍

@gjohansson-ST gjohansson-ST merged commit 340df38 into home-assistant:dev Jan 31, 2024
53 checks passed
@mill1000 mill1000 deleted the issue/fix_non_numeric_log_message branch January 31, 2024 19:27
@mill1000
Copy link
Contributor Author

Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants