Skip to content

Apply Precision/Scale/Offset to struct in modbus sensor#48544

Merged
MartinHjelmare merged 1 commit into
home-assistant:devfrom
janiversen:issue_44254
Apr 16, 2021
Merged

Apply Precision/Scale/Offset to struct in modbus sensor#48544
MartinHjelmare merged 1 commit into
home-assistant:devfrom
janiversen:issue_44254

Conversation

@janiversen
Copy link
Copy Markdown
Member

@janiversen janiversen commented Mar 31, 2021

The single values in struct are corrected with presicion, scale and offset,
just as it is done with single values.

Breaking change

Proposed change

the struct configuration e.g.

sensors:
  - name test1
  - data_type = custom
  - count = 8
  - struct = ">4f"

Could result in very long strings being delivered back, due to many decimal digits.

sensors:
  - name test1
  - data_type: custom
  - scale: 1
  - offset: 0
  - precision: 2
  - count: 8
  - struct: ">4f"

will cut the decimals to 2.

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

Example entry for configuration.yaml:

# Example configuration.yaml

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
  • 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:

@MartinHjelmare MartinHjelmare changed the title Precision/Scale/Offset applies to struct in modbus sensor. Apply Precision/Scale/Offset to struct in modbus sensor Mar 31, 2021
@janiversen
Copy link
Copy Markdown
Member Author

@vzahradnik did you see this PR ?

@vzahradnik
Copy link
Copy Markdown
Contributor

Not yet. I probably overlooked it. I will check.

@janiversen
Copy link
Copy Markdown
Member Author

thanks.

@janiversen janiversen mentioned this pull request Apr 7, 2021
21 tasks
The single values in struct are corrected with presicion, scale and offset,
just as it is done with single values.
@janiversen
Copy link
Copy Markdown
Member Author

@vzahradnik any comments here ? You wrote in one of your PR´s that you had a comment, and when that was solved you would approve.

It would be nice to get this merged alongside your PR´s so we can get modbus moving.

1 similar comment
@janiversen
Copy link
Copy Markdown
Member Author

@vzahradnik any comments here ? You wrote in one of your PR´s that you had a comment, and when that was solved you would approve.

It would be nice to get this merged alongside your PR´s so we can get modbus moving.

@vzahradnik
Copy link
Copy Markdown
Contributor

Interesting you don't see that. Let me give you a picture:
note

@janiversen
Copy link
Copy Markdown
Member Author

I know why you did not finalize your review :-)

The comment states the value is 1.00e-28 which is a very small number so it converts to 0.00. I did this on purpose to ensure that it worked with very small numbers.

@vzahradnik
Copy link
Copy Markdown
Contributor

OK, it makes sense now. I will approve. Thanks for clarification.

Comment thread tests/components/modbus/test_modbus_sensor.py
@janiversen
Copy link
Copy Markdown
Member Author

@MartinHjelmare you changed the title a while ago, do you have other review comments?

It would be nice to gave this in the next point release.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@MartinHjelmare MartinHjelmare added this to the 2021.4.6 milestone Apr 16, 2021
@MartinHjelmare MartinHjelmare merged commit ea9641f into home-assistant:dev Apr 16, 2021
@janiversen janiversen deleted the issue_44254 branch April 17, 2021 09:22
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2021
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 TCP - Function code 0x03 (read holding registers) - Cannot use all registers read

5 participants