Skip to content

Add option to compare energy graphs with previous period#12723

Merged
balloob merged 7 commits intodevfrom
compare-energy
May 20, 2022
Merged

Add option to compare energy graphs with previous period#12723
balloob merged 7 commits intodevfrom
compare-energy

Conversation

@bramkragten
Copy link
Copy Markdown
Member

Proposed change

Add option to compare energy graphs with previous period

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

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

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:


const dayDifference = differenceInDays(end || new Date(), start);
const period =
dayDifference > 35 ? "month" : dayDifference > 2 ? "day" : "hour";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😬

key: "energy_dashboard",
});
energyCollection.setCompare(this._compare);
energyCollection.refresh();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<ha-check-list-item left .selected=${this._compare}>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

collectionKey="energy_dashboard"
></hui-energy-period-selector>
`}
<ha-button-menu
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make this a button, "COMPARE DATA" maybe as label? Or this icon
image

balloob
balloob previously approved these changes May 18, 2022
Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

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

🎉

@@ -0,0 +1,113 @@
import { differenceInDays, endOfDay } from "date-fns";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
import { differenceInDays, endOfDay } from "date-fns";
import { differenceInDays, endOfDay } from "date-fns/esm";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should already use that as it has:

  "main": "index.js",
  "module": "esm/index.js",

in package.json?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh. Well I just fixed it everywhere else 😅

balloob
balloob previously approved these changes May 18, 2022
@balloob balloob enabled auto-merge (squash) May 20, 2022 04:10
@balloob balloob merged commit 6ab19d6 into dev May 20, 2022
@delete-merged-branch delete-merged-branch bot deleted the compare-energy branch May 20, 2022 04:20
@github-actions github-actions bot locked and limited conversation to collaborators May 21, 2022
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.

3 participants