Lovelace: Add deep press (3D touch) to existing cards

Good work, no i dont really have a reason for it, other than not needing it before.

I will add it right away

I pushed a quick fix to dev branch, version 1.1.1.b1, untested but it should work. Can you confirm?
You can update via HACS.

Just updated to 1.1.1.b1 through HACS. Works great! Thanks for the quick release.

Thereā€™s a weird issue though. I have haptic: heavy, so I can feel my iPhone trigger it twice by long pressing, which calls the service twice as well, but Iā€™m guessing it doesnā€™t have to do anything with your mod. If I release the touch screen on the first ā€˜haptic triggerā€™ it will only open one popup, thus one service call is triggered. Iā€™m guessing itā€™s something in the Button Card plugin.

Iā€™m glad it opens my popup windows now, which it didnā€™t at all (or 1 out 10 times trying) without your mod. Really awesome!

After playing around with it a bit, I realize now that it triggers the service on hold and on release.

I just added dbltap_action to the Button Card and that works fine (opens a single popup; does only one service call), but Iā€™m guessing it doesnā€™t use the Deep Press mod in that case.

So, Iā€™m guessing it does have something to do with this mod. @roflcoopter Do you have an idea what could be causing this?

It does work for me though. Though I use popup cards for it, it does the same thing as browser-mod afaik.

Hmm, i cannot reproduce this, for me it only triggers once.
Can you show me your lovelace config related to the issue so i can try it out?

Dear @roflcoopter would it be possible to add haptic feedback to this for iphones? The only card I know that can do this is the button card. Which is a shame as it would be nice to have on other cards as well.

What card are you using this with other than button-card?

For example simple-weather-card, picture-elements. Seeing you made a mod of this deep_press card I wondered if the same would be possible for haptics.

Ok, Iā€™ve been playing around with this a bit. Thereā€™s no issue at all on my MacBook.

The issue only occurs on my iPhone.

Iā€™ve tried several configurations with different results as can be seen below. It seems to be an issue when I use the Browser Mod with the browser_mod.command service and specifically popup as the command.

  • On My iPhone I have no issue at all with Deep Press when I use e.g. more-info as an action:
type: custom:button-card
entity: light.living_room
deep_press: true
tap_action:
  action: toggle
hold_action: &popup
  haptic: heavy
  action: more-info
dbltap_action:
  <<: *popup
  • On my iPhone I have no issue at all with Deep Press when I use e.g. call-service as an action with a simple script trigger. This obviously doesnā€™t show anything (so no double popup window), but it also does not trigger the script twice.
type: custom:button-card
entity: light.living_room
deep_press: true
tap_action:
  action: toggle
hold_action:
  haptic: heavy
  action: call-service
  service: script.turn_on
  service_data:
    entity_id: script.example
  • On my iPhone I have no issue at all with Deep Press when I use e.g. call-service as an action, browser_mod.command as a service and more-info as a command (only shows a single popup, as expected):
type: custom:button-card
entity: light.living_room
deep_press: true
tap_action:
  action: toggle
hold_action: &popup
  haptic: heavy
  action: call-service
  service: browser_mod.command
  service_data:
    command: more-info
    entity_id: light.living_room
dbltap_action:
  <<: *popup
  • On my iPhone I do have an issue with Deep Press when I use e.g. call-service as an action, browser_mod.command as a service and popup as a command. This shows two popups when I keep holding my iPhone until after the popup has shown.

    When I release the screen as soon as I see the popup, it only shows the popup window once, but if I keep pressing the screenā€¦ wait until the popup has shown and release like a second after, it will show the popup twice (below it).

type: custom:button-card
entity: light.living_room
deep_press: true
tap_action:
  action: toggle
hold_action: &popup
  haptic: heavy
  action: call-service
  service: browser_mod.command
  service_data:
    command: popup
    title: Title
    card:
      type: entities
      entities:
        - light.living_room
dbltap_action:
  <<: *popup

This also happens when I replace the entities card with something else, like the markdown card. So, this also triggers the issue:

type: custom:button-card
entity: light.living_room
deep_press: true
tap_action:
  action: toggle
hold_action: &popup
  haptic: heavy
  action: call-service
  service: browser_mod.command
  service_data:
    command: popup
    title: Title
    card:
      type: markdown
      content: 'Example.'
dbltap_action:
  <<: *popup

The above looks like the following:
two-popup-windows

So, this seems to happen in a very specific use-case. Do you think this can be fixed?

Edit:

Just tried it without the haptic: heavy option and having hold_action as the only action (so removing the tap_action and dbltap_action) and the issue still occurs.

Edit #2:

Just as a side-note: when I remove deep_press: true this issue doesnā€™t occur (showing two popups, that is), but it causes my original problem, which is that the popup doesnā€™t always show up.

Earlier I mentioned that it worked 1 out of 10 times, that might have been a bit exaggerated. It seems to work 1 out of 3 times now that Iā€™m debugging it.

Should be possible, ill take a look, probably during the weekend

Edit: @jimz011 Actually, all you have to do is add this to your simple-weater-cardconfig:

- type: custom:simple-weather-card
  ...
  deep_press: true
  hold_action:
    action: more-info
    haptic: heavy

and it works straight of the bat.
Unsure about picture elements tho, can you try?

Amazing report, thanks!

Iā€™ll try to mimic your setup and try to reproduce

New release 1.2.0
This release contains a few bugfixes and introduces the ability to disable deep-press on unsupported devices.

  • Fixes #1 with the new global config option enable_unsupported . See README on how to use this new config. @jimz011
  • Fixes a bug where the hold action would sometimes trigger twice. @thmry
  • Fixes compatibility with button-cards lock functionality.

Hi @roflcoopter sorry for the late reply. deep_press true on the simple weather card is indeed possible, however it has recently been updated and now it has a tap_action (only tap_action) that can be configured. That is what I actually meant. Also haptics are not supported by that card natively.

Another thing, since last update (1.2.0) deep press does not seem to work anymore on my iPhone X (iOS 13). If I add enable_unsupported: true it does work, however tap_action seems to be disabled on all cards with this setting on. It doesnā€™t matter if I set it to true or false the result stays the same.

For now I reverted back to an older version as those still do work. (could it have something to do that I am on a beta version of iOS?)

It was probably an error on my part. I pushed a new release for you to try out.
Let me know if there still are issues, might be something with iOS13

I have updated to that release but same thing happens. Though it does work now without adding that deep_press line to ui-lovelace.yaml

However it still blocks all tap_actions on most cards. Deep press itself works fine, but when enabled with the latest version it wonā€™t accept tap_actions on button-cards (tap_action does seem to work on the simple-weather-card though). It is odd.

Interesting, do you have an iOS12 device to test on?

I have an idea what could be wrong, ill look at it first thing in the morning!

I do have yes, my wife is still on ios 12. But I wonā€™t be able to test that until tonight. I will report here as soon as I do.

@roflcoopter so I have tried to play around with this on my two iphones. (iphone 7 plus on iOS 12.3 and an iPhone X on iOS 13 beta 7). My results with the latest version 1.2.1

iPhone 7 Plus:

  • deep_press and tap_action work as expected
  • after using a deep_press it will always do an extra click (which is a tap_action in most cases), I do not think this is intended

iPhone X:

  • deep_press works fine
  • no card can be tapped anymore, so all tap_actions feel like they are set to action: none (I know they arenā€™t, but the result looks somewhat similar)
  • it also does a tap_action after a deep_press like on the iPhone 7 Plus, weird thing is, it does work after a deep_press (e.g. I use a button to go back to the frontpage with a deep_press, when the lovelace view switches the button that was under my finger is now replaced with another button, it will press it once when I release my finger, that was still doing the deep_press action, and the button will turn on or off). Tapping the button again will do nothing as tapping does exactly nothing.

Sorry it is hard to explain without being able to actually show you what is going on XD sorry for the long explanation.

Anyways, it works fine with version 1.1.1b (with the exception of that same tap_action that it does after a deep_press, however with version 1.1.1b it only occasionally does that and not all the time unlike 1.2.0 and 1.2.1 do for me. I hope this helps.

I havenā€™t been able to test this out until now and it seems to work perfect. Thanks!

Iā€™m on iOS 12.4 on an iPhone 8 Plus and installed version 1.2.1 btw.

Also, I tried to reproduce what @jimz011 was saying about the deep_press triggering an extra click. I donā€™t think it happens here. After a deep_press on a button (e.g. for a light) it opens a popup window (as expected with my config) and does not toggle the light which would happen on a tap_action (as he mentioned). At least I think he meant that.