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 automation/script creation directly from clipboard #24506

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

jpbede
Copy link
Member

@jpbede jpbede commented Mar 4, 2025

Proposed change

Imagine you copied a automation or script YAML and want to create a new automation from it, you would have to create a new automation/script, switch to YAML mode, paste it and maybe switch back, if you want have the UI mode.
This PR adds now the ability to detect automation/script YAML in the clipboard and provide a option when creating a automation/script to directly create one from it.

Only downside on this, it only works in a secure context, or at least on Chrome when giving the clipboard permission manually.

Bildschirmaufnahme.2025-03-04.um.20.14.42.mov

@karwosts
Copy link
Contributor

karwosts commented Mar 5, 2025

It makes me a little uncomfortable that this means that anyone who visits the automation editor will get a browser popup saying that home-assistant wants permission to scan your clipboard, whether they use this feature or not. Just feels a bit icky to me.

@jpbede
Copy link
Member Author

jpbede commented Mar 5, 2025

Hm we could make this an opt-in feature, so the user would know why they gets this pop up. What do you think?

@karwosts
Copy link
Contributor

karwosts commented Mar 5, 2025

I think that would likely be reasonable, but I'll leave further comments to the UX people.

I think you can pre-query if you have permission, so maybe something like this in the popup (just an idea):

permission = queryPermission()

if(permission = prompt) {
  <list-item
    @onclick = scanClipboardForAutomation() && importFromClipboard()
  >
     Paste From Clipboard
     Home Assistant will request permission to read your clipboard.
  </list-item>
} else if (permission == granted && scanClipboardForAutomation()) {
   <list-item
     @onclick = importFromClipboard()
   >
     Paste From Clipboard
     Paste an automation from your clipboard
  </list-item>
} else if (permission == denied) {
   nothing
}

That only has the downside for people in the prompt category, that it adds a mostly useless item to the list when you don't have anything in the clipboard.

@MindFreeze MindFreeze added the Needs UX Pull requests requiring a review from the Home Assistant design team label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Needs UX Pull requests requiring a review from the Home Assistant design team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants