Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple tap/hold/doubletap actions. #8125

Closed
wants to merge 2 commits into from
Closed

Conversation

thomasloven
Copy link
Contributor

Proposed change

Add a new action type - multiple, which takes a list of actions: and perform them all.

Use case is e.g. if you have a layout like this https://www.youtube.com/watch?v=5y6rhwr5Y8c you may want to activate a script and get back to the start view with a single tap.

I was a bit worried about the maintenance burden, but with all the type checking it turns out to be only four lines of business logic in handle-action.ts and a single special case to handle in hui-action-editor.ts - which is all special cases already...

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

tap_action:
  action: multiple
  actions:
    - action: toggle
    - action: navigate
      navigation_path: /lovelace/default_view

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:

@oywino
Copy link

oywino commented Jan 17, 2021

I tried to accomplish exactly this by building a button-card:

image

But of course it failed. Although to me - the YAML structure I used seem logical, so I actually did expect it to work.

@thomasloven
Copy link
Contributor Author

thomasloven commented Jan 27, 2021

I'll take this back to the drawing board for a while.

Besides the merge conflict, confirmations can now only be applied to the individual actions inside the multiple action, not to the multiple action itself - which would make more sense if you had to choose one...

@@ -41,7 +41,11 @@ export const handleAction = async (
}

const actionConfigs =
actionConfig.action === "multiple" ? actionConfig.actions : [actionConfig];
actionConfig.action === "multiple"
? Array.isArray(actionConfig.actions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How I googled for this, which I assumed must be in js/ts somewhere. Should have git greped...

@github-actions
Copy link

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.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 27, 2021
@github-actions github-actions bot closed this May 4, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 5, 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.

None yet

4 participants