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

Support for hierarchy of individual energy devices #23185

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Dec 6, 2024

Proposed change

When adding individual devices to energy configuration, allow an entry to designate another entry as its parent. This will have the following effects:

  • When displaying the energy consumption of the parent in the stacked bar, subtract the energy consumption of the children, so that nested devices are not double (or triple) counted. This will also correct the untracked consumption.
  • When arranging the stack order for the bar chart, children will always be stacked adjacent to their parent.
  • When hiding the child entry in the bar chart, the parent item then fills the chart space of the hidden child.

Consider the following example, which has a montior on the breaker, but also monitors on individual items downstream of the breaker. In the current implementation the child items would be double counted, significantly throwing off the untracked calculation, and making the total height of the energy stack much higher than the true consumption.

With this change they would be "nested" within the parent item, and therefore the remaining area of each parent item then becomes the "untracked energy" remaining in that parent, or the energy not consumed by known tracked children.

nested-energy

I realize the actual visualization of the hierarchy is a bit weak here, there may be additional options in chartjs to improve this, or maybe can do something in the tooltip, not sure yet.

This also works for >1 level nesting, so you could have breaker -> smart power strip -> individual item if you wanted.

There hasn't been any work done yet on visualizing this for the summary bar graph, but that doesn't strictly need to be implemented for this to be correct. Could do more in the future.

This has still a bit more work to do polishing the configuration UI, but just wanted an early feedback if this is something of interest.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

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

@karwosts karwosts added wip Backend Change Required Requires a Backend Core Code Change panel: energy labels Dec 6, 2024
@home-assistant home-assistant bot added cla-signed WTH Issues & PRs generated from the "Month of What the Heck?" labels Dec 6, 2024
@karwosts
Copy link
Contributor Author

karwosts commented Dec 6, 2024

@MindFreeze - saw you were also working on some energy charts, was curious if you think this is a worthwhile idea or would be something you're interested in leveraging as well.

@MindFreeze
Copy link
Contributor

I would definitely leverage this in a Sankey Chart if we have it. We have even discussed something like this for the future. We'll need to review it from a UX perspective though

@MindFreeze MindFreeze added the Needs UX Pull requests requiring a review from the Home Assistant design team label Dec 6, 2024
@karwosts
Copy link
Contributor Author

karwosts commented Dec 6, 2024

I haven't added it yet, but would probably just add a select selector in the device configuration dialog, to select one of the other devices (and filter it to prevent from selecting a cyclic loop).

@MindFreeze
Copy link
Contributor

We could also link a power entity this way

@karwosts
Copy link
Contributor Author

karwosts commented Dec 6, 2024

We could also link a power entity this way

For what purpose?

@MindFreeze
Copy link
Contributor

To display real time power consumption. There is a WTH thread for this.

@karwosts
Copy link
Contributor Author

karwosts commented Dec 7, 2024

Config UI:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Needs UX Pull requests requiring a review from the Home Assistant design team panel: energy wait for backend WTH Issues & PRs generated from the "Month of What the Heck?"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants