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

fix: Fix double tap on iOS devices #1858

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

Conversation

webjib
Copy link
Contributor

@webjib webjib commented Jan 27, 2025

This should fix the issue where iOS devices were unable to get the double tap action working.
Tested on a real iPhone, iOS 18.3.

@github-actions github-actions bot added the bug Something isn't working label Jan 27, 2025
@dermotduffy
Copy link
Owner

@webjib For some reason this does not seem to work for me (testing using Browserstack on iPhone 16 iOS v18). This is my config, simply turn on/off a light. Works fine in any browser I can test on, does not work on iOS using this PR (or before):

type: custom:frigate-card
cameras:
  - camera_entity: camera.office
    live_provider: go2rtc
  - camera_entity: camera.kitchen
    live_provider: webrtc-card
live:
  zoomable: false
  actions:
    entity: light.office_main_lights
    double_tap_action:
      action: toggle
  controls:
    builtin: false
menu:
  style: outside

Would you mind sharing your config and I'll try that?

@webjib
Copy link
Contributor Author

webjib commented Jan 28, 2025

I've tested again, with a fresh fork, it's still working.
Actually, I can't explain why this "cancelled" variable could have an effect on the double tap feature. There's seem to be an issue with the events triggered on the iPhone, and maybe this is not really a fix, but a side effect.

Here is my full config:

type: custom:frigate-card
cameras:
  - camera_entity: camera.reolink_sub
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
      stream: reolink_sub
    dimensions:
      layout:
        fit: cover
        position:
          "y": 100
      aspect_ratio: "3:2"
live:
  controls:
    builtin: false
  actions:
    double_tap_action:
      action: custom:frigate-card-action
      frigate_card_action: ptz_digital
      ptz_action: zoom_in
      absolute:
        zoom: 1.7
menu:
  buttons:
    frigate:
      enabled: false
      icon: mdi:menu
    cameras:
      enabled: false
    substreams:
      enabled: false
    live:
      enabled: false
    mute:
      enabled: true
      permanent: true
    microphone:
      enabled: true
      priority: 46
      type: toggle
      permanent: true
    display_mode:
      enabled: false
    media_player:
      enabled: false
    timeline:
      enabled: false
    fullscreen:
      enabled: false
      permanent: true
      icon: mdi:arrow-expand
    camera_ui:
      enabled: false
    download:
      enabled: false
    snapshots:
      enabled: false
    clips:
      enabled: false
    screenshot:
      enabled: false
      permanent: false
  button_size: 48
overrides:
  - conditions:
      - condition: media_loaded
        media_loaded: true
    merge:
      menu:
        buttons:
          fullscreen:
            enabled: true
status_bar:
  style: none
dimensions:
  aspect_ratio: "3:2"
profiles: []
performance:
  features:
    card_loading_indicator: false
elements:
  - type: custom:frigate-card-conditional
    conditions:
      - condition: media_loaded
        media_loaded: true
    elements:
      - type: custom:frigate-card-menu-icon
        permanent: true
        alignment: opposing
        icon: mdi:camera
        tap_action:
          action: perform-action
          perform_action: camera.snapshot
          data:
            entity_id: camera.reolink_sub
            filename: >-
              /media/Doorbell/Snapshots/snapshot_{{
              now().strftime('%Y%m%d-%H%M%S')}}.jpg

@dermotduffy
Copy link
Owner

@webjib I'm not sure what to do here. I still cannot get this to work using your PR in BrowserStack, but it apparently works for you. That normally might be fine, but the fact neither of us currently understands why this works for you is a little unsettling ;-)

Do you have multiple iOS devices you could test this on, just to make sure?

@webjib
Copy link
Contributor Author

webjib commented Feb 2, 2025

I agree with you. I can test on another iPhone, on an iPad and on a virtual iOS device through Xcode.

By the way, could you tell me why we can’t use the exact same full code than Home Assistant?
https://github.com/home-assistant/frontend/blob/dev/src/panels/lovelace/common/directives/action-handler-directive.ts

@dermotduffy
Copy link
Owner

By the way, could you tell me why we can’t use the exact same full code than Home Assistant?

The card supports things HA doesn't, e.g. actions on the start or end of a tap (for controlling a PTZ camera, or microphone, for example). Both HA, and the card, also have different utility functions (e.g. the card has a nice class for timers). They could certainly be made more similar though, but I wouldn't bother unless there's a problem that we can demonstrably say works with one but not the other. As of yet, I have not been able to see how the HA code performs better in this instance (I did try just using the whole HA code block and it didn't seem to perform any differently in my Browserstack test setup).

@webjib
Copy link
Contributor Author

webjib commented Feb 3, 2025

Thanks for your detailed answer! I'll try to test on other devices and I will get back to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

double_tap_action has no effect on iOS
2 participants