Copy content to clipboard when clicking a card

Hi all,

I want to have a card which allows to copy some data into my clipboard (mainly on home assistant Android app).

The need is to copy to clipboard the content of the input text ‘etsy_link_x’ when clicking on ‘etsy_x’. (Which I update throught a webscrapper script).

Do you think it is possible ? Any help would be greatly appreciated.
Thx!

Perhaps if you manage to fire an intent that copies the text from a command notification.
Have a look at command notifications and intents, then try and find an intent that can copy to clipboard.

Hi @Hellis81, thx for your answer, it is a really good idea.

I tried to create such a service but I didn’t managed to make it work without format issue.

service: notify.mobile_app_pixel_6_pro
data:
  message: "command_activity"
  title: "?text:test"
  data:
    channel: "com.google.android.apps.docs.app.SendTextToClipboard"
    tag: "android.intent.action.SEND"
    

I don’t know if any of parameters are the good one (channel nor tag nor title…) and I can’t find any documentation about it. Have you any idea about what channel or tag or title to use ? I guess it need some type of URI for the title but I don’t know the expected format.

I have no clue. What you posted seems reasonable but I have really no clue at all.

I suggest you move the thread to Android app since I doubt this is something that can be done in frontend.
Perhaps with javascript when I think about it. But I believe that means you need to use the browser then.

Thx for your help, I will give a try on “Mobile Apps” Category.

Here’s how I got it to work.

Use a custom button card and use this:

type: custom:button-card
entity: input_text.notify_last_say
tap_action:
  action: put_anything_here_but_an_official_value
  whatever_literaly: |
    [[[
      // this is javascript code
      navigator.clipboard.writeText(entity.state);
    ]]]
name: entity.state
icon: mdi:content-copy

This will work on a HTTPS (secured) site after you give it permission with your browser.

Clipboard permission is disabled by default on Chrome for HTTP (unsecured) sites.
You can change that with a setting:

1 Like

Hi @OzStone, the solution is nice but you need to be on a browser and being in the companion app is mandatory for me in this case.

Thx for your help

this works well both on browser and companion app on iOS. Thank you!

the solution proposed by @OzStone works on the companion app on iOS