Proposal: Lovelace strategies#6273
Conversation
|
An example of a view strategy is a battery view strategy that will generate a view with all battery statuses grouped by rooms. I can also see view strategies as a way for dashboard strategies to defer calculations until a user opens the view. So for example a strategy that creates a view per room would just generate a view config per room without actually sorting all the entities, as the view strategy can do that. |
|
|
||
| const tag = `ll-strategy-${name.substr(CUSTOM_PREFIX.length)}`; | ||
|
|
||
| return customElements.whenDefined(tag).then(() => customElements.get(tag)); |
There was a problem hiding this comment.
This is the awesome part of this. We will use the custom elements registry as a dependency manager.
zsarnett
left a comment
There was a problem hiding this comment.
Awesome Idea. I am not sure of the technical if it will work but looks awesome
b50b1ba to
ccee083
Compare
|
So I am trying to understand how we would const dashboardStrategy = await getLovelaceDashboardStrategy("default"); // using `get-strategy.ts
const dashboardStrategyInstance = new dashboardStrategy(); // Create an instance of the class
const dashboardConfig = await dashboardStrategyInstance.generateDashboard({ hass: this.hass!, lovelace: this.lovelace?.config }); // Call the function on the instanceThis is how I am finding we would have to do this since we are using functions in the class. But I feel like I may be missing something. |
|
The method will be defined as static methods, so we won't need to instantiate the strategy. const dashboardStrategy = await getLovelaceDashboardStrategy("default");
const dashboardConfig = await dashboardStrategy.generateDashboard({ hass: this.hass!, lovelace: this.lovelace?.config }); // Call the function on the instance |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
The other day I was on a call with @bramkragten and @zsarnett and we were talking frontend and we talked about LL dashboard generate strategies. Here is a proposal of how this could work. I just created the types, no actual implementations.
Adds:
This would allow people to share strategies that will create cards. People can add as many crazy options to their strategies as they wish.
The idea of strategies already exists in our codebase. If no Lovelace config exists, we will automatically generate one.