How to create a button

I’m trying to create a button that could be on the dashboard and when pressed could send a notification or message to a user.

I’ve thought create an automation to do this … or a sensor but not sure what would work here then a button for the view so another user can press it to send the message.

Suggestions if anyone has one :slight_smile:

Thank you!

Just create a script with the notification.
Add the script to the dashboard.

1 Like

This is what I did…

I created an automation to be fired by button press like this:

                     - type: 'custom:button-card' 
                        show_name: true
                        icon: mdi:heart
                        hold_action:
                          action: none
                        tap_action:
                          action: call-service
                          service: automation.trigger
                          service_data:
                            entity_id: automation.42c_thinking_about_you
                        entity: automation.42c_thinking_about_you
                        name: Thinking about you
                        type: entity-button
                        show_icon: true

Info is an example but it works!

No… That is not what you did.
You created an automation when what you needed was a script

An automation is triggered by something, a script is triggered by someone.
Subtile difference but it will be confusing if you start mixing things like this. And depending on the trigger of your automation it might trigger when you don’t want.

2 Likes

I do this regularly. I create a binary sensor and use the change state node in nodered to fire the automation. You can also use the change state node to turn the binary sensor off when it gets turned ON Or use ‘tap action’ / ‘toggle option’ to turn it off.

1 Like

My Script example:

thinking:
  sequence:
    - service: notify.mobile_app_sm_f926u1
      data:
        message: "TTS"
        title: "Thinking about you"
        data:
          channel: alarm_stream_max
          ttl: 0
          priority: high

Frontend view example:

             - type: 'custom:button-card' 
                show_name: true
                icon: mdi:heart
                hold_action:
                  action: none
                tap_action:
                  action: call-service
                  service: script.turn_on
                  service_data:
                    entity_id: script.thinking
                entity: script.thinking
                name: Thinking
                type: entity-button
                show_icon: true

Thanks for the input!!! Now I can create a button that triggers a script! :slight_smile: