Explain use of collection_key for energy cards (#37335)

* Update energy.markdown

* Update energy.markdown

* Typo

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
karwosts 2025-02-06 10:30:54 -08:00 committed by GitHub
parent 66f1215145
commit 77063bc223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -234,3 +234,28 @@ The following example limits the number of shown devices to 5:
type: energy-devices-detail-graph type: energy-devices-detail-graph
max_devices: 5 max_devices: 5
``` ```
## Using Multiple Collections
By default, all energy cards are linked to any `energy-date-selection` card on the view, and all `energy-date-selection` cards are linked to the same period. To enable multiple different date selections on the same view, it is necessary to link them to different collections. This is done by adding the variable `collection_key` to the card YAML, and giving this a value of any custom string that begins with `energy_`. (strings that do not start with `energy_` will generate an error).
All energy cards support use of `collection_key` option.
### Examples
Example view with multiple collections:
```yaml
type: masonry
path: example
cards:
- type: energy-date-selection
- type: energy-date-selection
collection_key: energy_2
# This card is linked to the first (default) date selection
- type: energy-usage-graph
# This card is linked to the second date selection
- type: energy-usage-graph
collection_key: energy_2
```