Skip to content

Add precision parameter to dsmr sensor#19873

Merged
MartinHjelmare merged 5 commits into
home-assistant:devfrom
zumitnl:dsmr-precision
Jan 31, 2019
Merged

Add precision parameter to dsmr sensor#19873
MartinHjelmare merged 5 commits into
home-assistant:devfrom
zumitnl:dsmr-precision

Conversation

@zumitnl
Copy link
Copy Markdown
Contributor

@zumitnl zumitnl commented Jan 8, 2019

Description:

I was working with the DSMR sensor for reading the power and gas usage.
It uses floats with 3 digits and was filling up the database really quickly.
I've added the precision parameter to make the number of digits configurable.
It works now beter with the value 2.

First I changed it in the file after every update, but I've tried to do my first pull request for this to fix this into the future.

Related issue (if applicable): fixes #

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#8106

Example entry for configuration.yaml (if applicable):

# Power (DSMR)
- platform: dsmr
  port: /dev/ttyUSB1
  dsmr_version: 5
  precision: 2

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @zumitnl,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@ghost ghost added the in progress label Jan 8, 2019
Comment thread homeassistant/components/sensor/dsmr.py Outdated
Comment thread homeassistant/components/sensor/dsmr.py Outdated
Copy link
Copy Markdown
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.

Instead of passing the full config object in to the device entity, you could just pass the precision.

Comment thread homeassistant/components/sensor/dsmr.py
Comment thread homeassistant/components/sensor/dsmr.py Outdated
@zumitnl
Copy link
Copy Markdown
Contributor Author

zumitnl commented Jan 30, 2019

I've tested the precision parameter also with the latest version 0.86.4.
What is the next step?

@MartinHjelmare MartinHjelmare changed the title Added precision parameter to dsmr sensor Add precision parameter to dsmr sensor Jan 31, 2019
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! @dgomes are you ok with this?

@MartinHjelmare MartinHjelmare merged commit e20c2aa into home-assistant:dev Jan 31, 2019
@ghost ghost removed the in progress label Jan 31, 2019
@balloob balloob mentioned this pull request Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants