Open SeanPM5 opened 5 years ago
It's just a firing of an event, so easy enough...the # of options in this card are starting to melt my brain...
Nice, I'll look into that once I'm finished with the typescript conversion, seems quite easy :+1:
Also yeah so much options...
@SeanPM5, could you please try this file and let me know the result as I don't own an IOS device? https://raw.githubusercontent.com/custom-cards/button-card/haptic/dist/button-card.js
Usage:
tap_action/hold_action:
action: usual stuff
[...]
haptic: success | warning | failure | light | medium | heavy | selection
(Will change to haptics
instead of haptic
later... typo in the code :) )
Have to wait until next beta build of the Home Assistant iOS app becomes available before I can test it (scheduled for ~Thursday/tomorrow I think~ 0.92.1), but that will definitely be the very first thing I try and I'll report back.
Thanks for adding this!
@SeanPM5 is getting me a few test cases and I'll try them out and let you know if it works @RomRider. Thanks for implementing, you are the first! I plan to add support for Android in the official app that I am beginning work on soon, although my basic research tells me that Android generally doesn't have a nice "taptic engine" like iPhone does so not sure if I'll be able to accurately replicate the patterns as defined by the iOS HIG.
As I said on the PR, all is working fine.
I didn't plan to release it like this it is in the PR but we can as a sort of MVP.
I don't know the feeling of it, as currently it's going to vibrate when you release the screen with your finger. Maybe what we can imagine is to have:
tap_action.haptic
(or light
if undefined and on_hold
is different from none
) on_hold
use the haptic from it, if anyThoughts @SeanPM5 @robbiet480?
Also @robbiet480, when this feature is released on this button, where should the users download the "beta" ios app with haptic support included?
@RomRider http://home-assistant.io/ios/beta
Merged and released. I'll keep this open to gather feedback.
Almost forgot, here was the test config I did, contains all seven different haptic levels and was confirmed working by Robbie. So when the next iOS beta app releases this should be a good and fast way to try it out.
#### IOS HAPTIC TEST CONFIG - https://github.com/custom-cards/button-card/issues/121
- type: horizontal-stack
cards:
- type: "custom:button-card"
entity: sun.sun
color_type: card
color: green
icon: mdi:check-circle
name: Success Haptic
show_state: false
tap_action:
action: more-info
haptic: success
- type: "custom:button-card"
entity: sun.sun
color_type: card
color: "#f9c536"
icon: mdi:alert
name: Warning Haptic
show_state: false
tap_action:
action: more-info
haptic: warning
- type: "custom:button-card"
entity: sun.sun
color_type: card
color: "#ff0000"
icon: mdi:message-alert
name: Failure Haptic
show_state: false
tap_action:
action: more-info
haptic: failure
- type: horizontal-stack
cards:
- type: "custom:button-card"
entity: sun.sun
color_type: card
icon: mdi:feather
name: Light
show_state: false
tap_action:
action: more-info
haptic: light
- type: "custom:button-card"
entity: sun.sun
color_type: card
icon: mdi:medium
name: Medium
show_state: false
tap_action:
action: more-info
haptic: medium
- type: "custom:button-card"
entity: sun.sun
color_type: card
icon: mdi:pig
name: Heavy
show_state: false
tap_action:
action: more-info
haptic: heavy
- type: "custom:button-card"
entity: sun.sun
color_type: card
icon: mdi:selection-off
name: Selection
show_state: false
tap_action:
action: more-info
haptic: selection
Thanks again guys!
The iOS beta was released a few hours ago, I have been testing haptics on the button-card it and it works very well. The subtle physical feedback makes quite the difference in my opinion. Awesome stuff, I plan to update every single one of my buttons to use it.
The problem I've sorta noticed very quickly though with the current implementation, is that syntax is nested under tap_action
and hold_action
. So if your custom:button-card doesn't have either of those things, there's no way to add haptic (easily at least). For example I have many cards like this:
- type: custom:button-card
entity: switch.vizio_tv
icon: mdi:television
name: TV
color_type: card
color: "#7CBE6E"
and this:
#### PODCASTS TOGGLE
- type: custom:button-card
icon: mdi:podcast
name: Podcasts
color_type: card
state:
- value: 'on'
color: "#f9c536"
entity: input_boolean.display_podcasts
service:
domain: input_boolean
action: toggle
data:
entity_id: input_boolean.display_podcasts
among others that do not have tap_action
or hold_action
specified, that I want to add haptics to...
I kind of think haptic should be top level option too, so in the above example you could just add the one line:
- type: custom:button-card
entity: switch.vizio_tv
icon: mdi:television
name: TV
color_type: card
color: "#7CBE6E"
haptic: light
@SeanPM5, if I understand correctly, because you don't want to have to define the toggle action each time (as it's the default action), you'd like to have a main config entry for haptic
. Is that correct?
On a side note, this config is not valid:
#### PODCASTS TOGGLE
- type: custom:button-card
icon: mdi:podcast
name: Podcasts
color_type: card
state:
- value: 'on'
color: "#f9c536"
entity: input_boolean.display_podcasts
service: # <----- This doesn't exist anymore, but it works because toggle is default :)
domain: input_boolean
action: toggle
data:
entity_id: input_boolean.display_podcasts
Or should haptic be default?
Correct @RomRider . I wish to add haptic to all of my buttons, and I suspect that most people would want to do the same. If it was a main config entry it'd be a lot easier to update them all without needing to add tap_action
and such on buttons that don't necessarily need it.
But I think @iantrich idea would work well, if haptic was default for all buttons then people wouldn't need to update anything at all in most cases (unless they wished to override the default sensitivity for a certain button by adding haptic: heavy
for example).
The other benefit of making it default, is that is how the iOS app does it with the core entity-buttons etc so the behavior would be familiar and consistent, especially for those who have a mixture of default entity-button and custom-button inside of the same view.
@SeanPM5, what would be the best option for the default value? Is that light
?
If we have a default value, I'll also add an option to disable haptics (haptic: none
)
Sorry for the late response, I had been meaning to test and got busy the last few days and lost track.
I think that light
would be a good default value, and haptic: none
is a great idea as well.
There's also a toggle inside of iOS itself (under Sounds & Haptics section) that users can disable haptics across the entire operating system - and the Home Assistant iOS app respects that OS-level setting too. So users that don't like haptics at all will likely have disabled it from that OS setting already.
You can get an idea of what it's like in the middle of this page where it says "Haptic Feedback." On the right side of that page you can test the haptic levels which plays a sound and animation. It's not the same as actually feeling it on the device, but it should give you a more better idea. After playing with that page, I think you will agree that light
is probably the best default.
Just revisiting this now that support was added to core. Starting in Home Assistant 0.99 it's now sending light
haptic by default on the core entity button. PR here: https://github.com/home-assistant/home-assistant-polymer/pull/3569
So I think that it would be a smart idea to match the behavior of core button with this card and send light
by default.
We will want to add a none
option for haptic then.
This will require a modification in custom-card-helper
For none? I don't think so. If passed to forwardHaptic is will just not produce anything. The other option is to have button-card set light as the default
Any chance to adapt this code to work on the android APP?
Normal Buttons also emit an Vibration Event in the Android App. Could this be also implemented into custom:button-card? Or is this an Android Companion thing?
@iantrich any chance of this getting through for Android too?
Robbie has added haptics support to the official Home Assistant iOS app (update releasing in a day or two). The PR for it is here (requires 0.92 also releasing in a day from now): https://github.com/home-assistant/home-assistant-polymer/pull/3099
Haptics basically vibrates the part of the screen that you touch (in a subtle way), so you get physical feedback on button presses like in real life. It's very nice.
As per balloob's comment at the bottom of that PR, it appears that custom cards can also use this new feature:
It seems that you just have to fire a certain event when button is pressed and the iOS app will listen for that event and then handle the vibration/haptics part. Robbie is active on Discord #ios channel and could help out with any implementation questions I'm sure.
It would be a truly killer feature to have this supported in button-card as well. And I think would even be much better than the official entity-button implementation because we'd be able to specify exact sensitivity level on per-button basis, for example
haptics: light
(possible options seem to include: success, warning, failure, light, medium, heavy, selection)Hopefully this can be considered. I would be happy to help test things.