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

Utility meter #19718

Merged
merged 38 commits into from Jan 26, 2019

Conversation

Projects
None yet
7 participants
@dgomes
Copy link
Member

dgomes commented Jan 2, 2019

Description:

A utility meter sensor provides functionality to track consumptions of various utilities (e.g. energy, gaz, water, heating). From a User perspective utility meters operate in cycles (usually monthly) for billing purposes, this sensor will automatically reset the counter based on the configured cycle. On a reset an attribute will store the previous counter, providing the means for comparison operations ("did I spend more or less this month?")

Services have been added to support complex scenarios such as peak energy tariffs in which during the operation cycle the meter might need to be paused for some time.

Related issue (if applicable): fixes #

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

Example entry for configuration.yaml (if applicable):

utility_meter:
  energy:
    source: sensor.energy
    cycle: hourly
    tariffs:
      - peak
      - offpeak
  water:
    source: sensor.test_sensor

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 communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

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

@wafflebot wafflebot bot added the in progress label Jan 2, 2019

@emontnemery emontnemery referenced this pull request Jan 2, 2019

Merged

Add an Integration sensor #19703

5 of 9 tasks complete

@dgomes dgomes referenced this pull request Jan 2, 2019

Merged

Utility meter #8025

2 of 2 tasks complete
@dgomes

This comment has been minimized.

Copy link
Member Author

dgomes commented Jan 4, 2019

Thanks for the valuable feedback @OttoWinter ! Think the PR got much better :)

@dgomes dgomes added Ready for review and removed in progress labels Jan 6, 2019

@dgomes dgomes referenced this pull request Jan 13, 2019

Closed

Sensor - Adding services #131

@dgomes dgomes force-pushed the dgomes:utility_meter branch from 46a5c19 to 702d2bb Jan 15, 2019

dgomes added some commits Jan 1, 2019

dgomes added some commits Jan 7, 2019

@dgomes dgomes force-pushed the dgomes:utility_meter branch from 702d2bb to 2411403 Jan 16, 2019

dgomes added some commits Jan 16, 2019

@dgomes

This comment has been minimized.

Copy link
Member Author

dgomes commented Jan 19, 2019

OK, I took the opportunity of moving things into a component and made a major refactor that moves the services into a new entity, making more obvious the use case for the services.

If you think the change is too big, I can close this PR and re-open it.

Show resolved Hide resolved homeassistant/components/utility_meter/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/sensor.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/__init__.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/sensor.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/sensor.py Outdated
Show resolved Hide resolved homeassistant/components/utility_meter/sensor.py Outdated
@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

If test coverage is good, we can merge after last comment is addressed.

@fabaff fabaff merged commit 1d5ffe9 into home-assistant:dev Jan 26, 2019

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on utility_meter at 92.906%
Details

@wafflebot wafflebot bot removed the Ready for review label Jan 26, 2019

mxworm added a commit to mxworm/home-assistant that referenced this pull request Jan 27, 2019

Utility meter (home-assistant#19718)
* initial commit

* test service calls

* lint

* float -> Decimal

* extra tests

* lint

* lint

* lint

* lint

* fix self reset

* clean

* add services

* improve service example description

* add optional paused initialization

* fix

* travis fix

* fix YEARLY

* add tests for previous bug

* address comments and suggestions from @OttoWinter

* lint

* remove debug

* add discoverability capabilities

* no need for _hass

* Update homeassistant/components/sensor/utility_meter.py

Co-Authored-By: dgomes <diogogomes@gmail.com>

* Update homeassistant/components/sensor/utility_meter.py

Co-Authored-By: dgomes <diogogomes@gmail.com>

* correct comment

* improve error handling

* address @MartinHjelmare comments

* address @MartinHjelmare comments

* one patch is enought

* follow @ballob suggestion in home-assistant/architecture#131

* fix tests

* review fixes

* major refactor

* lint

* lint

* address comments by @MartinHjelmare

* rename variable

fredrike added a commit to fredrike/home-assistant that referenced this pull request Jan 30, 2019

Utility meter (home-assistant#19718)
* initial commit

* test service calls

* lint

* float -> Decimal

* extra tests

* lint

* lint

* lint

* lint

* fix self reset

* clean

* add services

* improve service example description

* add optional paused initialization

* fix

* travis fix

* fix YEARLY

* add tests for previous bug

* address comments and suggestions from @OttoWinter

* lint

* remove debug

* add discoverability capabilities

* no need for _hass

* Update homeassistant/components/sensor/utility_meter.py

Co-Authored-By: dgomes <diogogomes@gmail.com>

* Update homeassistant/components/sensor/utility_meter.py

Co-Authored-By: dgomes <diogogomes@gmail.com>

* correct comment

* improve error handling

* address @MartinHjelmare comments

* address @MartinHjelmare comments

* one patch is enought

* follow @ballob suggestion in home-assistant/architecture#131

* fix tests

* review fixes

* major refactor

* lint

* lint

* address comments by @MartinHjelmare

* rename variable

@balloob balloob referenced this pull request Feb 6, 2019

Merged

0.87.0 #20794

@RezzZ

This comment has been minimized.

Copy link

RezzZ commented Feb 9, 2019

awesome work! Question though, the offset description is a bit unclear to me. If I add yearly meters and want to reset on the 1st of may each year, how do I then calculate the the offset? Is it the nr of seconds between 00:00 Januari 1st till 00:00 May 1st?

@dgomes

This comment has been minimized.

Copy link
Member Author

dgomes commented Feb 9, 2019

Please don't comment in closed/merged issues

The offset is provided in the previous unit (yearly -> offset in months)

For further comments please use the community or open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment