-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add option to compare energy graphs with previous period #12723
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
Changes from 3 commits
e71adf6
e96cf90
f31e4f9
d654d24
affdc1e
de21f67
9a9da99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import "@polymer/app-layout/app-header/app-header"; | ||
| import "@polymer/app-layout/app-toolbar/app-toolbar"; | ||
| import "@material/mwc-tab"; | ||
| import "@material/mwc-tab-bar"; | ||
| import { mdiDotsVertical } from "@mdi/js"; | ||
| import "@polymer/app-layout/app-header/app-header"; | ||
| import "@polymer/app-layout/app-toolbar/app-toolbar"; | ||
| import { | ||
| css, | ||
| CSSResultGroup, | ||
|
|
@@ -12,14 +13,16 @@ import { | |
| } from "lit"; | ||
| import { customElement, property, state } from "lit/decorators"; | ||
| import "../../components/ha-menu-button"; | ||
| import "../../components/ha-button-menu"; | ||
| import "../../components/ha-check-list-item"; | ||
| import { LovelaceConfig } from "../../data/lovelace"; | ||
| import "../../layouts/ha-app-layout"; | ||
|
|
||
| import { haStyle } from "../../resources/styles"; | ||
| import "../lovelace/views/hui-view"; | ||
| import { HomeAssistant } from "../../types"; | ||
| import { Lovelace } from "../lovelace/types"; | ||
| import { LovelaceConfig } from "../../data/lovelace"; | ||
| import "../lovelace/components/hui-energy-period-selector"; | ||
| import { Lovelace } from "../lovelace/types"; | ||
| import "../lovelace/views/hui-view"; | ||
| import { getEnergyDataCollection } from "../../data/energy"; | ||
|
|
||
| const LOVELACE_CONFIG: LovelaceConfig = { | ||
| views: [ | ||
|
|
@@ -41,6 +44,8 @@ class PanelEnergy extends LitElement { | |
|
|
||
| @state() private _lovelace?: Lovelace; | ||
|
|
||
| @state() private _compare = false; | ||
|
|
||
| public willUpdate(changedProps: PropertyValues) { | ||
| if (!this.hasUpdated) { | ||
| this.hass.loadFragmentTranslation("lovelace"); | ||
|
|
@@ -81,6 +86,19 @@ class PanelEnergy extends LitElement { | |
| collectionKey="energy_dashboard" | ||
| ></hui-energy-period-selector> | ||
| `} | ||
| <ha-button-menu | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| corner="BOTTOM_START" | ||
| @action=${this._toggleCompare} | ||
| > | ||
| <ha-icon-button | ||
| .label=${this.hass.localize("panel.menu")} | ||
| .path=${mdiDotsVertical} | ||
| slot="trigger" | ||
| ></ha-icon-button> | ||
| <ha-check-list-item left .selected=${this._compare}> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's show this as a "comparing mode enabled" bar in the UI at the top. Probably ha-alert? |
||
| Compare with previous period | ||
| </ha-check-list-item> | ||
| </ha-button-menu> | ||
| </app-toolbar> | ||
| </app-header> | ||
| <hui-view | ||
|
|
@@ -118,6 +136,15 @@ class PanelEnergy extends LitElement { | |
| }; | ||
| } | ||
|
|
||
| private _toggleCompare() { | ||
| this._compare = !this._compare; | ||
| const energyCollection = getEnergyDataCollection(this.hass, { | ||
| key: "energy_dashboard", | ||
| }); | ||
| energyCollection.setCompare(this._compare); | ||
| energyCollection.refresh(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need to refresh if compare is now true and it's not loaded for current period yet? |
||
| } | ||
|
|
||
| static get styles(): CSSResultGroup { | ||
| return [ | ||
| haStyle, | ||
|
|
||

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