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

Allow modbus min/max temperature to be negative. #109977

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

janiversen
Copy link
Member

Breaking change

Proposed change

Min/Max temperature in a household climate control are positive, but some configurations use HA to control a freezer or similar, so they need to set a negative min/max.

Test case added to avoid further regressions.

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 Ruff (ruff format 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:

Comment on lines 194 to 195
CONF_MIN_TEMP: -23,
CONF_MAX_TEMP: -57,
Copy link
Contributor

Choose a reason for hiding this comment

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

Having the max temp lower than the min temp doesn't make sense, maybe a check for that would be good?

Copy link
Member Author

@janiversen janiversen Feb 8, 2024

Choose a reason for hiding this comment

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

Not true, it would be fairly normal for a freezer.

it really depends on your interpretation of max/min e.g, the freezer can max freeze to x or a aircon can max cool down to x.

We do not want to make checks that impose not needed limits on configurations

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to be sure I was not being theoretical, I checked my refrigerator, it says "max: -19", and "min: -5", lthe current temp is "-7", so max lower than min is making sense for that one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, then I haven't said anything 😅 Thanks for checking!

Copy link
Contributor

@bouwew bouwew Feb 8, 2024

Choose a reason for hiding this comment

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

@janiversen The convention is that the negative number closest to 0 is the maximum number.
I've known this since lower school, a long time ago :)
And internet "says' the same, google it.
Don't rely on a single wrong occurrence please :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing is unfortunately that freezer logic is not neccessarily real math logic. The question is if we want to be strict and say that max > min should always be true.

Copy link
Contributor

@bouwew bouwew Feb 8, 2024

Choose a reason for hiding this comment

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

@autinerd good point, calculation-rules show that -23 is the max value.
Freezer logic does not exist, that's just a wrong construct by someone that doesn't know the normal conventions :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a nice theoretical discussion, but this PR allows min/max temperatures to be negative, not more not less.

Adding a check on min/max values (of which there are 7-8 different in modbus) is another PR...and I for one believe if a user wants to configure max lower than min, then he sure have reasons, and does it make HA less robust to allow that...

Copy link
Member Author

Choose a reason for hiding this comment

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

But in order to avoid a heated discussion, I have changed the test (it really does not matter to the test), so that it now reads:

              CONF_MIN_TEMP: 23,
              CONF_MAX_TEMP: 57,

in the hope we can move on, and actually get the bug fixed, so the user who filed the issue can continue using his configuration.

Copy link
Contributor

@bouwew bouwew left a comment

Choose a reason for hiding this comment

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

LGTM!

@janiversen janiversen merged commit 9f50153 into home-assistant:dev Feb 8, 2024
47 of 49 checks passed
@mstoffel-sag
Copy link

Thanks Guys really appreciate your fast and very good work!!

@janiversen janiversen deleted the solve_109958 branch February 8, 2024 13:28
@frenck frenck mentioned this pull request Feb 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2024
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.

Modbus climate is no longer accepting negative values.
6 participants