AmoebeLabs / swiss-army-knife-card

The versatile custom Swiss Army Knife card for Home Assistant allows you to create your unique visualization using several graphical tools, styling options and animations.
244 stars 21 forks source link

Support for custom popups in the actions configuration #203

Closed AmoebeLabs closed 1 year ago

AmoebeLabs commented 1 year ago

The Problem To Be Solved

The current implementation supports the following user actions:

Displaying a custom popup window is not possible.

Additional background:

See: https://community.home-assistant.io/t/lovelace-versatile-swiss-army-knife-custom-card/432419/95

Related Issues (if any)

(Optional): Suggested Solution

For now, check how other cards allow for custom popups, and check if this configuration can be re-used for consistency with other cards...

Most examples use the browser_mod extension to allow for custom popups using the fire-dom-event action and browser_mod configuration:

    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          title: Some Popup
          content:
            type: entities
              - !include ../folder-with-popups/popup.yaml

The custom-card-helpers has this solution in https://github.com/custom-cards/custom-card-helpers/blob/master/src/handle-click.ts:

    case "fire-dom-event": {
      fireEvent(node, "ll-custom", actionConfig);
      if (actionConfig.haptic) forwardHaptic(actionConfig.haptic);
      break;

actionConfig contains the full configuration of the action, so includes the .action field for instance.

Using browser_mod means support for fire-dom-event in the actions configuration and eventhandler in SAK, which is a combination of handleTapEvent() and _processTrapEvent().

Looking from the other side: support for fire-dom-event means support for all the browser_mod callable functions, including notifications and more!

(Optional): Alternative Solutions

AmoebeLabs commented 1 year ago

In some cases, after a restart, the following error pops up:

image