swiss-army-knife-card icon indicating copy to clipboard operation
swiss-army-knife-card copied to clipboard

Support more than 1 entity to be passed to a tool

Open AmoebeLabs opened this issue 2 years ago • 0 comments

The Problem To Be Solved

All of the current tools support 1 entity: the entity which its state is based upon. Simple and straightforward. No problems.

However, in some cases:

  • having more entities makes it possible to hide/unhide a tool, say based on the on/off state of another entity.
  • an entity with say min/max attributes can't be used currently, but with this extension, it can!

Additional background:

The tool will always base its state on a single entity (the first one in the list in this case), but of course, some extra JavaScript using a derived_entity can make any combination of different states and attributes!

Related Issues (if any)

(Optional): Suggested Solution

An example of the YAML definition could be:

  • a simple list of indexes, where the first one is the primary entity_index
  • the animations section gets an extra entity_index if not the default entity_index. So existing animations don't have to change (nonbreaking change!!)
  • template animations should receive the entity_index as a variable: easy!
  • in the case of multiple entities, the reuse should be automatically set to true, to make sure that all those animations merge the created styling, instead of resetting the styling for each entity. Or maybe a separate setting, merge or so, as the reuse is meant to preserve styling from the previous/last state...
      entity_indexes:
        - entity_index: 1
        - entity_index: 0
        - entity_index: 2
      animations:
        - state: 'on'
          styles:
            circslider:
              fill: red
        - state: 'off'
          styles:
            circslider:
              fill: green
        - state: 'on'
          entity_index: 0
          reuse: true
          styles:
            circslider:
              display: initial
        - state: 'off'
          entity_index: 0
          styles:
            circslider:
              display: none

(Optional): Alternative Solutions

AmoebeLabs avatar Jul 26 '22 07:07 AmoebeLabs