Skip to content

Add modbus min/max values#86131

Merged
janiversen merged 8 commits into
home-assistant:devfrom
GrahamJB1:modbus_min_max_value
Feb 2, 2023
Merged

Add modbus min/max values#86131
janiversen merged 8 commits into
home-assistant:devfrom
GrahamJB1:modbus_min_max_value

Conversation

@GrahamJB1
Copy link
Copy Markdown
Contributor

Proposed change

Add optional min_value (with optional min_value_threashold) and max_value (with optional max_value_threashold)

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

if min_value is set:
If value < min_value_threshold, return min_value
Note: min_value_threshold defaults to min_value
if max_value is set:
If value > max_value_threshold, return max_value
Note: max_value_threshold defaults to max_value

  • Link to documentation pull request: TBD, once agreed

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

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

Code owner commands

Code owners of modbus 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 modbus Removes the current integration label and assignees on the issue, add the integration domain after the command.

Copy link
Copy Markdown
Member

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

Documentation and tests are missing.

Comment thread homeassistant/components/modbus/base_platform.py Outdated
Comment thread homeassistant/components/modbus/base_platform.py Outdated
Comment thread homeassistant/components/modbus/base_platform.py Outdated
Comment thread homeassistant/components/modbus/base_platform.py Outdated
@janiversen
Copy link
Copy Markdown
Member

While drinking coffee, I was thinking about your problem....it seems to me you do not want a min_value but zero_supression which is quite a different functionality, and something that would make a lot of sense to add.

In case do not know, zero_supression with X means if -X < value < X, X becomes 0

@GrahamBarnett
Copy link
Copy Markdown

OK.. that was my original impl ! Will do this in different pr and remove thresholds so there are just min/max value

@GrahamJB1
Copy link
Copy Markdown
Contributor Author

So we now have:
min_value, max_value, zero_clamp_value
Unit tests added.
Let me know if you are OK and I will prepare docs

Copy link
Copy Markdown
Member

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

Mainly just a naming problem.

Comment thread homeassistant/components/modbus/const.py Outdated
CONF_TARGET_TEMP,
CONF_VERIFY,
CONF_WRITE_TYPE,
CONF_ZERO_CLAMP_VALUE,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a strange name, the industry uses “zero_supress”, please change.

Comment thread homeassistant/components/modbus/base_platform.py Outdated
@janiversen
Copy link
Copy Markdown
Member

With the name changed and documentation added (green light from CI) this PR will get my approval.

Copy link
Copy Markdown
Member

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

Approved, thanks.

I cannot hit the approve button or merge, before the document PR is available. Remember to base the document PR on “next” (since this is a new feature).

@MartinHjelmare MartinHjelmare changed the title modbus min/max values Add modbus min/max values Jan 20, 2023
@GrahamJB1
Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Member

@janiversen janiversen 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 8bff950 into home-assistant:dev Feb 2, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 3, 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.

3 participants