custom button card templates don't render with fire-dom-event (possibly same as ticket #8)
Hi,
Love this mod! That the haptic feedback comes when the hold_action kicks in (and not after you raise your finger which is kind of pointless) is great.
I recently upgraded to use fire-dom-event for popups in my custom button card (as the old method is no longer supported) and unfortunately deep-press now no longer works with the button card and browser_mod. I have a minimal view that shows the problem:
title: Test
views:
- path: testit
title: deeppresstest
cards:
- type: custom:button-card
icon: mdi:lightbulb
entity: light.smart_plug_dimmer
# deep_press: true
hold_action:
action: fire-dom-event
haptic: success
browser_mod:
command: popup
title: "[[[ return 'test text' ]]]"
card:
type: entities
entities:
- '[[[ return entity.entity_id ]]]'
This works: a long press brings up an entities card with correct title ("test text") and entity.
However if I uncomment the deep_press line the templates aren't rendered at all - they show up as the unrendered template. So the title of the entities card becomes
[[[ return 'test text' ]]]
and the entities card complains that
[[[ return entity.entity_id ]]]
isn't a valid entity.
It'd be great if I could use this mod again.
(I think this is the same issue as ticket #8 btw).
Just discovered that if I use browser_mod's alternate way of specifying the popup (using a separate popup_cards entry, so no fire-dom-event) it does work, so this is definitely related to the handling of fire-dom-event:
title: Test
views:
- path: testit
title: deeppresstest
popup_cards:
light.smart_plug_dimmer:
title: My popup test
card:
type: entities
entities:
- light.smart_plug_dimmer
cards:
- type: custom:button-card
icon: mdi:lightbulb
entity: light.smart_plug_dimmer
# deep_press: true
hold_action:
action: more-info
haptic: success
So there is a workaround. But it means having to specify everything with a popup (almost all of my entities and badges) in 2 separate locations as well as having to duplicate around 30 lines of yaml for every one of them:-(
I'd be happy to help with this if you can give me a heads-up on where to start. I've looked at the code but it's not clear where the fire-dom-event stuff would go.
Sorry you are having issues. Unfortunately i dont have much time for this project atm.
deep-press is using https://github.com/custom-cards/custom-card-helpers to handle clicks, maybe that can be upgraded and solve this? Not sure.
The click is handled here
I looked at custom-card-helpers and handleClick but it's unclear where it's going wrong. It seems like deep_press is somehow short-circuiting the custom button card so it doesn't get a chance to do the rendering. I'm going to look further.
Anyway, tnx for a great mod.
Yeah it kind of does. It injects itself into each card using the same method as card_mod. However, card_mod has been rewritten in TypeScript so it's a bit harder to copy that logic now