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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state class total increasing to Tasmota energy today sensor #77140

Merged
merged 1 commit into from Sep 6, 2022

Conversation

ollo69
Copy link
Contributor

@ollo69 ollo69 commented Aug 22, 2022

Proposed change

I think that energy today sensor should have associated the state class Total Increasing. This sensor grows every days and is reset at midnight, representing the daily used energy. Adding the state class will allow to use this sensor in the energy dashboard, better than use the sensor energy total.

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

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:

@probot-home-assistant
Copy link

Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration (tasmota) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@project-bot project-bot bot added this to Needs review in Dev Aug 22, 2022
@emontnemery
Copy link
Contributor

@ollo69 Thanks for the PR! Why is it better to use the energy today sensor for statistics than the energy total sensor?

@ollo69
Copy link
Contributor Author

ollo69 commented Aug 22, 2022

From my point of view it is more clear to understand from where the counter start providing values for energy consuming and provide more flexibility in adding / removing counter to the energy dashboard.

@emontnemery
Copy link
Contributor

I think it's rather confusing to allow selecting either the today or the total sensor for statistics, and the result for the user will be exactly the same. We recommend that an integration only makes one sensor which provides a certain type of data, for example energy consumption, available for statistics for that reason.

@ollo69
Copy link
Contributor Author

ollo69 commented Aug 22, 2022

Ok, understand your point. In this case you don't think that at least energy total should be changed to total increasing? If for instance this sensor will be reset at device level (eg due to a firmware update and memory reset), we will have a decrease of energy consumed equal total energy read until today. Or, as different approach, just leave the energy today as total increasing and totally remove state class from energy total (but this sound like a breaking change)

@emontnemery
Copy link
Contributor

The problem with total_increasing is that it will trigger new cycles anytime the meter's reading decreases, are we sure no energy meters which are supported by Tasmota can do that, either because the underlying driver is buggy and sometimes returns an incorrect value, or because the meter is a net meter, i.e. decreases when energy is produced.

@ollo69
Copy link
Contributor Author

ollo69 commented Aug 22, 2022

I'm only using Sonoff Pow, so I don't know about possible reading decrease. But at the end doesn't seems so a bad idea having also the energy today to be able to choose the right sensor depending on the usage and device type. At this moment I'm using an utility meter based on energy today sensor, and it is working well, but I would simplify configuration using directly the tasmota sensor. I'm really worried about using energy total for this now, because a reset of this sensor could compromise all my statistics.

@ollo69
Copy link
Contributor Author

ollo69 commented Aug 28, 2022

Any thoughts about this PR?

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

I don't think this is great, but we don't yet have a way to group sensors.

Ideally there should be flags on the today and total energy sensors, to make it clear they're different views of the same data.

Dev automation moved this from Needs review to Reviewer approved Sep 6, 2022
@emontnemery emontnemery merged commit 3327493 into home-assistant:dev Sep 6, 2022
Dev automation moved this from Reviewer approved to Done Sep 6, 2022
@ollo69 ollo69 deleted the tasmota_energy_stateclass branch September 6, 2022 10:04
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants