-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Enable Statistics Graph card to integrate with Energy Dashboard #21105
Enable Statistics Graph card to integrate with Energy Dashboard #21105
Conversation
WalkthroughWalkthroughThe changes enhance the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant HuiStatisticsGraphCard
participant EnergyAPI
participant SubscriptionService
User->>HuiStatisticsGraphCard: Modify card configuration
note right of HuiStatisticsGraphCard: Handles new property `energy_date_selection`
HuiStatisticsGraphCard->>SubscriptionService: Subscribe to updates
SubscriptionService-->>HuiStatisticsGraphCard: Provide updates
HuiStatisticsGraphCard->>EnergyAPI: Request energy data (with optional date selection)
EnergyAPI-->>HuiStatisticsGraphCard: Return energy data
HuiStatisticsGraphCard-->>User: Display updated statistics graph
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Additional context usedBiome
Additional comments not posted (2)
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
0cc1302
to
16e6129
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
public hassSubscribe() { | ||
if (!this._config?.energy_date_selection) { | ||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the config changes, the subscriptions are now not updated, so behaviour in the editor will be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain more? Are you saying that if a user uses the editor to uncheck energy_date_selection
, nothing will force the plot to be redrawn with the now-static time period?
Is this moot now that I reverted the editor changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subscription is created on init of the element, so if some one enables the energy_date_selection
option after the element was initialised, it will not add the subscription and thus miss data/not work.
This is not just for the visible editor, but also for the YAML editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we can not use hassSubscribe
here, it will not work in the card editor.
Why is |
src/panels/lovelace/editor/config-elements/hui-statistics-graph-card-editor.ts
Outdated
Show resolved
Hide resolved
Adds boolean option `energy_date_selection` to Statistics Graph card. If true, the graph will set its time range to that specified by an Energy Date Picker card on the same dashboard, similar to the plots on the Energy Dashboard.
PR reviewer suggested it was too confusing, especially without dynamically hiding the overridden days_to_show option.
and instead activate when collection_key is specified
16e6129
to
95cebdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
95cebdb changes the behavior to trigger when What is the intended behavior? Is it acceptable to call I'm ultimately trying to interop with two other community integrations here, energy-period-selector-plus and ha-sankey-chart, so if Thus, I'm pretty sure I should revert 95cebdb and restore the |
Yeah |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
getEnergyDataCollection(this.hass!, { | ||
key: this._config?.collection_key, | ||
}).subscribe((data) => { | ||
this._setFetchStatisticsTimer(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not pass the data to this function, as the function is also called in other places, save the data you need (the dates) in the class and then call the _setFetchStatisticsTimer
function.
Because there hasn't been any activity on this PR for quite some time now, I've decided to close it for being stale. Feel free to re-open this PR when you are ready to pick up work on it again 👍 ../Frenck |
Hi @madsciencetist is there any news on this one? Being able to use the datepicker in any statistics graph card would be amazing! It has so much potential to present the data. This is something I am already searching for a very long time :-) |
@timvdsm There are still two unresolved comments, and I'm not familiar enough with this project to understand the comment about not using |
I'm making an attempt at picking this up in #23478 |
Proposed change
Adds boolean option
energy_date_selection
to Statistics Graph card. Iftrue, the graph will set its time range to that specified by an Energy
Date Picker card on the same dashboard, similar to the plots on the
Energy Dashboard. Otherwise,
days_to_show
will be used as before.Type of change
Example configuration
Additional information
This PR fixes or closes issue: N/A
This PR is related to issue or discussion:
Link to documentation pull request:
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit