Skip to content

Sketch out strategies#8959

Merged
balloob merged 15 commits into
devfrom
strategy-proposal
Apr 23, 2021
Merged

Sketch out strategies#8959
balloob merged 15 commits into
devfrom
strategy-proposal

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Apr 21, 2021

Breaking change

Proposed change

Continues my and @zsarnett's work from #6273.

This adds support for strategies to Home Assistant.

The first strategy will be our auto generated Lovelace dashboard.

Strategies will have the ability to pre-process the Lovelace config. It can either generate a complete new one, or can be used to adjust what is currently there. Strategies have access to the hass object and can query any data from the backend that they need (ie area registry, or some custom data).

Here is an example custom strategy https://gist.github.com/balloob/bf2715efba46420d6ba1a01586946308

To do:

  • Disable editing UI when strategy based (YAML is ok)
  • Add support for view strategies in hui-view.ts
  • Check HA-Cast support
  • Pass in narrow into generation
  • Take Control should render all strategies.

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:

@balloob balloob force-pushed the strategy-proposal branch from bdeb77a to 91205c7 Compare April 22, 2021 16:47
Comment thread src/panels/lovelace/strategies/original-states-strategy.ts Outdated
Comment thread src/panels/lovelace/strategies/get-strategy.ts
import type { SaveDialogParams } from "./show-save-config-dialog";

const EMPTY_CONFIG = { views: [] };
const EMPTY_CONFIG: LovelaceConfig = { views: [{ title: "Home" }] };
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.

This one has bothered me for so long. When it's emtpy, it's not clear how you can add a card, because we have no view. Just adding a stub view to get creation of cards going.

Comment thread src/panels/lovelace/views/hui-view.ts Outdated
this.hass.themes !== oldHass.themes ||
this.hass.selectedTheme !== oldHass.selectedTheme)
) {
applyThemesOnElement(
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 now don't set the theme on init, but only when the theme changes, we should also do this in _initializeConfig.

@balloob balloob merged commit 63e1031 into dev Apr 23, 2021
@balloob balloob deleted the strategy-proposal branch April 23, 2021 16:36
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 25, 2021
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.

4 participants