#Is it possible to send an event via custom button card tape action?

1 messages · Page 1 of 1 (latest)

foggy rune
#

This is a snippet of a custom button card. I want to use it to create an even when the user presses the button. I know how to do this with a action/service call but the events seem to be formatted differently. This is what I am trying but it isn't working:

    card:
      type: custom:button-card
      name: Dismiss
      show_icon: false
      show_name: true
      tap_action:
        event: viewassist
        event_data:
          action: dismiss alarm
          entity_id: "[[[ return variables.var_assistsat_entity ]]]"

In an automation I am able to send this command similar to this:

actions:
  - event: viewassist
    event_data:
      action: dismiss alarm

Is it possible to send an event via custom button card tape action?

arctic dagger
#

are you sure about that syntax? Normally something like that would be an action/service

#

Events are something you listen to for triggers and the like

foggy rune
arctic dagger
#

fair enough, it's likely the variables.var_assistsat_entity - you don't seem to have defined it anywhere

#

you need to create a "variables" key in the card that looks like:

   card:
      type: custom:button-card
      name: Dismiss
      show_icon: false
      show_name: true
      variables:
        var_assistsat_entity: entity_id_to_return
      tap_action:
        event: viewassist
        event_data:
          action: dismiss alarm
          entity_id: "[[[ return variables.var_assistsat_entity ]]]"
foggy rune
# arctic dagger fair enough, it's likely the variables.var_assistsat_entity - you don't seem to ...

Apologies, but I am only providing a small snippet of the code. This is a work in progress for my project View Assist. Here's a direct link to that view:

https://github.com/dinki/View-Assist/blob/viewassist-timers_release/View Assist dashboard and views/views/alarm/alarm.yaml

The variable is certainly defined as I am trying to change from a normal action call to the event call I posted in the OP.

GitHub

View Assist provides visual feedback for the Home Assistant Assist Voice Assistant - dinki/View-Assist

arctic dagger
#

i see, well I don't know if you can trigger an event like that from custom button cards.. if it works in an automation you should be able to make it work in a script and then run the script from the button card

remote slate
#

Yes you can't fire a manual event from a tap action. Has to be in a service script.

#

Though that might change in the future. Saw a work in progress PR to merge the sequence and tap-action concepts.