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

Add support for Energy Production CC sensors #93839

Merged
merged 3 commits into from May 31, 2023

Conversation

raman325
Copy link
Contributor

Proposed change

Adds support for Energy Production CC sensors in the zwave_js integration. Please review the state classes, particularly the use of TOTAL for today's energy production, which I wasn't 100% on.

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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

Hey there @home-assistant/z-wave, mind taking a look at this pull request as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zwave_js can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign zwave_js Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@raman325 raman325 marked this pull request as draft May 31, 2023 02:11
homeassistant/components/zwave_js/discovery.py Outdated Show resolved Hide resolved
homeassistant/components/zwave_js/sensor.py Show resolved Hide resolved
homeassistant/components/zwave_js/sensor.py Outdated Show resolved Hide resolved
tests/components/zwave_js/test_sensor.py Outdated Show resolved Hide resolved
@raman325 raman325 marked this pull request as ready for review May 31, 2023 03:39
(prev_value := event_data["args"]["prevValue"]) is not None
and (new_value := event_data["args"]["newValue"]) is not None
and prev_value > new_value
and self.state_class == SensorStateClass.TOTAL
Copy link
Member

Choose a reason for hiding this comment

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

Why do we use this kind of check? Don't we know the time of last reset since it's called "today"? Otherwise maybe we should just use state class TOTAL_INCREASING instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Today is relative to what the device thinks right? I have no way of knowing what today represents for the device at the moment. I will switch to TOTAL_INCREASING instead

Copy link
Member

Choose a reason for hiding this comment

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

If the device collects data for a certain time period I'd expect it to either report the time period or define the time period criteria so we can keep track of time ourselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, perhaps we can switch back to total later when we have a better understanding of how to get time. It would also be nice to get a device dump for a device that actually has this CC

tests/components/zwave_js/test_sensor.py Outdated Show resolved Hide resolved
@MartinHjelmare MartinHjelmare merged commit 1eb1ea0 into home-assistant:dev May 31, 2023
24 checks passed
@raman325 raman325 deleted the energy_production branch May 31, 2023 13:51
@github-actions github-actions bot locked and limited conversation to collaborators Jun 1, 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.

None yet

2 participants