Skip to content

Commit a8b0e9d

Browse files
committed
feat: Energy dashboard integration! See energy_date_selection in README
1 parent 7bc2444 commit a8b0e9d

File tree

13 files changed

+896
-563
lines changed

13 files changed

+896
-563
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
1212
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
1313
"@typescript-eslint/no-non-null-assertion": "off",
14-
"@typescript-eslint/ban-ts-comment": "off"
14+
"@typescript-eslint/ban-ts-comment": "off",
15+
"@typescript-eslint/explicit-module-boundary-types": "off"
1516
}
1617
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This card is intended to display connections between entities with numeric state
1919
| ----------------- | ------- | ------------ | ------------------- | ------------------------------------------- |
2020
| type | string | **Required** | | `custom:sankey-chart`
2121
| sections | list | **Required** | | Entities to show divided by sections, see [sections object](#sections-object) for additional options.
22+
| energy_date_selection | boolean | **Optional** | false | Integrate with the Energy Dashboard. Filters data based on the `energy-date-selection` card. Use this only for accumulated data sensors (energy/water/gas) and with a `type:energy-date-selection` card. You still need to specify all your entities as HA doesn't know exactly how to connect them. In the future we may use areas to auto configure the chart.
2223
| title | string | **Optional** | | Optional header title for the card
2324
| unit_prefix | string | **Optional** | | Metric prefix for the unit of measurment. See <https://en.wikipedia.org/wiki/Unit_prefix> . Supported values are m, k, M, G, T
2425
| round | number | **Optional** | 0 | Round the value to at most N decimal places. May not apply to near zero values, see issue [#29](https://github.com/MindFreeze/ha-sankey-chart/issues/29)

__tests__/__snapshots__/basic.test.ts.snap

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`SankeyChart aaaaaaaaaaaa 1`] = `
3+
exports[`SankeyChart matches a simple snapshot 1`] = `
44
"<!---->
55
<ha-card tabindex="0" label="Sankey Chart">
66
<div class=" container " style="height:200px;">
@@ -161,3 +161,9 @@ exports[`SankeyChart aaaaaaaaaaaa 1`] = `
161161
}
162162
</style>"
163163
`;
164+
165+
exports[`SankeyChart matches a simple snapshot 1`] = `
166+
"<!---->
167+
<sankey-chart-base></sankey-chart-base>
168+
"
169+
`;

__tests__/basic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ describe('SankeyChart', () => {
3838
sankeyChart = window.document.createElement(ROOT_TAG) as SankeyChart;
3939
// @ts-ignore
4040
sankeyChart.hass = hass as HomeAssistant;
41-
document.body.appendChild(sankeyChart);
4241
});
4342

4443
afterEach(() => {
@@ -61,6 +60,7 @@ describe('SankeyChart', () => {
6160
],
6261
};
6362
sankeyChart.setConfig(config);
63+
document.body.appendChild(sankeyChart);
6464
await sankeyChart.updateComplete;
6565

6666
expect(sankeyChart.shadowRoot?.innerHTML.replace(/<!--.+-->/g, '')).toMatchSnapshot();

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"license": "MIT",
1717
"dependencies": {
1818
"custom-card-helpers": "^1.7.2",
19+
"date-fns": "^2.29.3",
1920
"home-assistant-js-websocket": "^5.11.1",
2021
"lit": "^2.0.0-rc.2"
2122
},
@@ -51,6 +52,7 @@
5152
"start": "rollup -c rollup.config.dev.js --watch",
5253
"build": "npm run lint && npm run rollup",
5354
"lint": "eslint src/*.ts",
54-
"rollup": "rollup -c"
55+
"rollup": "rollup -c",
56+
"test": "jest"
5557
}
5658
}

0 commit comments

Comments
 (0)