logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

Home Assistant - how to create an event trigger button, MQTT, dashboard panel

p.kaczmarek2 6192 1

TL;DR

  • Home Assistant dashboard button triggers selected automations and can publish MQTT commands to control Tasmota or OpenBeken devices.
  • The button uses the visual Dashboard card editor, then calls MQTT Publish with a group topic such as cmnd/bekens/COMMAND.
  • The setup targets Home Assistant 2023.11.2 with Frontend 20231030.2, and OBK uses a group topic called bekens.
  • MQTT dry tests in the HA tab and the OpenBeken log confirmed that the published commands were received and executed.
  • Older Home Assistant versions may require slightly different steps.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Home Assistant user interface with Slow Blink LEDs button
    Here I will show you how to create a simple, scriptable button in Home Assistant. Our button will be displayed on the Dashboard and will activate the automation we have selected. I will also show how you can script this button to publish data to MQTT when pressed. Finally, I will demonstrate how you can with one publish control multiple Tasmota or OBK devices.

    The theme is based on Home Assistant 2023.11.2 (Frontend 20231030.2). In older versions, the steps may be slightly different, please update if necessary.

    We start from the entrance in Edit dashboard : :
    Screenshot of Home Assistant dashboard with a list of devices and dashboard edit option.
    Then, to add a card with buttons, click Add Card : :
    Screenshot of Home Assistant interface with the option to add a new card.
    There are many possibilities here, but today we focus on the button, so we choose Button : :
    Interface for adding cards in Home Assistant with the Button option selected.
    Now we configure our button. You don't have to select an Entity, but it's worth giving it a name and an icon.
    Button card configuration in Home Assistant with open fields to fill in.
    Click ShowCode Editor will show us the Yaml code of our button, but it is more convenient to use the visual editor.
    Button card configuration in Home Assistant with YAML code.
    I figured I'd create a trigger button slow animation of blinking LEDs in the room . I gave it an appropriate name and icon:
    Home Assistant button card configuration with a snail icon.
    When the button is pressed, the event we have selected will be performed. I chose Call Service -> MQTT Publish , i.e. triggering the publication of data on the MQTT service.
    To publish, you need to know what you are publishing and on what topic.
    Tasmota and OBK offers us separate MQTT topics for our device, and group topics under which many devices can listen. These are the so-called group topic , as seen in the OBK configuration below:
    MQTT configuration for BK7231T_WB3S_WhiteStripWindows device
    For me, it's a group topic bekens , and the full topic on which you can send commands is cmnd/bekens/COMMAND , where payload MQTT are the command arguments.
    In OpenBeken, on the LittleFS panel, I prepared a simple script with a loop performing a pseudo-animation of LED blinking. A very simple script, it just waits for a while, changes the brightness, waits again, changes the brightness again and then loops:
    LittleFS interface with an edited anim.bat script
    In the main autoexec.bat I defined aliases, i.e. my own commands to start and stop this script:
    Screenshot showing the editing of the /autoexec.bat file in OpenBeken.
    And then, finally, in the MQTT HA tab I "dry" tested whether the properly prepared MQTT publish was received and processed correctly by OBK:
    MQTT packet publishing interface with filled topic and QOS.
    The tests showed that the mechanism on the OBK side works, so we return to the button.
    In the button we enter what should be published on MQTT:
    MQTT button card configuration in Home Assistant with a publish topic.
    Then you can choose QOS and retain settings, I left them default:
    Button card configuration window in Home Assistant with QoS and Retain options.
    After approval, our button will appear on the panel:
    Home Assistant dashboard with Slow Blink LEDs button featuring a snail icon.
    In the OpenBeken log you can easily see whether our button is working. Received MQTT publications on listened topics are written to the log.
    Screenshot of OpenBeken MQTT log showing incoming publications on the topic 'cmnd/bekens/stop_blink'.

    For the more ambitious, here's the YAML code for my button:
    Code: YAML
    Log in, to see the code

    Similarly, you can create other buttons for other animations or a button to turn off the animation.

    Sources
    Sending a command via MQTT to Tasmota (also compatible with OpenBeken):
    https://tasmota.github.io/docs/Commands/#with-mqtt
    Group topic Tasmoty (MQTT topic for multi-device control, OpenBeken compatible):
    https://tasmota.github.io/docs/Commands/#mqtt
    OBK documentation, scripts:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md

    Summary
    To sum up:
    - Home Assistant allows you to create fully scriptable buttons that can trigger various types of automations, services, as well as publish data via MQTT
    - group MQTT topic allows you to control many Tasmota or OBK devices at the same time (you can, for example, group devices together by room or role)
    - OBK allows you to create simple scriptable animations and automation that can be triggered externally via MQTT
    This was, of course, just an example, such buttons can be used to launch selected scenarios or device operating modes, you can, for example, create a button that turns off all the lights in the house, or "prepares" the room before your return (turns on the heating, turns on the lights), you can prepare various buttons for various lighting scenarios (work - cold white, relaxation - warm white), etc.
    Do you use scriptable buttons on the Home Assistant panel, and if so, what functions do you give them? Feel free to share your ideas.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14622 posts with rating 12639, helped 655 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 20820556
    ro-x
    Level 14  
    Posts: 193
    Rate: 131
    I use scripted buttons to control a Vaillant stove, where the ebusd daemon listens to commands via MQTT. To read the current furnace settings, I use automation that is fired every minute - MQTT commands are also fired here.
📢 Listen (AI):

FAQ

TL;DR: In 3 steps, "Call Service" turns one Home Assistant dashboard button into a multi-device MQTT trigger. This FAQ is for Home Assistant, Tasmota, and OpenBeken users who want one panel button to launch scripts, scenes, or room actions through mqtt.publish and group topics such as cmnd/bekens/slow_blink. [#20819967]

Why it matters: A single dashboard button can trigger repeatable room automations without exposing complex MQTT commands every time.

Option Button target Multi-device control Script support shown in thread
Home Assistant + Tasmota mqtt.publish service Yes, via group topic Not demonstrated in detail
Home Assistant + OpenBeken mqtt.publish service Yes, via group topic Yes, LittleFS script + aliases

Key insight: The thread’s core pattern is simple: put the logic on the device side, then let Home Assistant send one short MQTT command from a dashboard button.

Quick Facts

  • The walkthrough was built on Home Assistant 2023.11.2 with Frontend 20231030.2, so older menus may differ slightly. [#20819967]
  • The sample button calls mqtt.publish with qos: 0 and retain: false, and publishes to cmnd/bekens/slow_blink. [#20819967]
  • The OpenBeken example uses one group topic named bekens, so one MQTT command can reach multiple devices that listen on that topic. [#20819967]
  • The sample automation stores a looping LED animation in OpenBeken LittleFS, then starts or stops it through aliases defined in autoexec.bat. [#20819967]
  • Another user runs boiler automation on a 1-minute cycle, using MQTT commands both for Vaillant control and for reading current furnace settings through ebusd. [#20820556]

How do I create a scriptable button in a Home Assistant dashboard that triggers an MQTT publish action?

Create a Button card and set its tap action to call the mqtt.publish service. 1. Open Edit dashboard and choose Add CardButton. 2. Give the button a name and icon. 3. Set Tap action to Call ServiceMQTT Publish, then enter the topic and payload values you want to send. The thread’s example publishes to a command topic and leaves QoS and retain at their defaults. [#20819967]

What MQTT topic and payload format should I use in Home Assistant to control multiple Tasmota or OpenBeken devices with one button?

Use a group command topic and send the command as the MQTT payload. The thread uses the group topic bekens, so the full command topic becomes cmnd/bekens/COMMAND, where COMMAND is replaced by the action name and the payload carries the command arguments. In the shown button, the topic is cmnd/bekens/slow_blink, which triggers the selected OpenBeken behavior across listeners on that group topic. [#20819967]

How do group topics work in Tasmota and OpenBeken for multi-device MQTT control?

Group topics let multiple devices listen for the same MQTT command. In the thread, both Tasmota and OpenBeken support this pattern, so one publish to a shared topic can control several devices at once. "Group topic" is an MQTT topic category that targets many devices with one message, using one shared listener name instead of separate per-device topics. That makes room-level or role-based control much simpler from one Home Assistant button. [#20819967]

What is a group topic in MQTT, and how is it used with Tasmota or OBK devices?

A group topic is a shared MQTT address used for multi-device commands. In this thread, the group name is bekens, and the command path is described as cmnd/bekens/COMMAND. Devices configured to listen on that shared topic react to the same publish, so one dashboard button can launch the same action on several Tasmota- or OpenBeken-compatible nodes in one room or device group. [#20819967]

How can I test whether an MQTT publish from Home Assistant is being received correctly by an OpenBeken device?

Test the publish first in the OpenBeken MQTT HA tab, then confirm it in the device log. The author did a dry test to verify that the prepared MQTT publish was received and processed correctly before returning to the Home Assistant button. After that, the OpenBeken log showed received MQTT publications on listened topics, which confirmed that the button path worked end to end. [#20819967]

What does the Home Assistant button YAML look like for calling the mqtt.publish service?

It uses a Button card with tap_action: call-service and service: mqtt.publish. The thread’s YAML sets show_name: true, show_icon: true, type: button, qos: 0, retain: false, topic: cmnd/bekens/slow_blink, icon: mdi:snail, and name: Slow Blink LEDs. That is a complete working example for a dashboard button that publishes one MQTT command when tapped. [#20819967]

How do I create OpenBeken aliases in autoexec.bat to start and stop a LittleFS LED animation script over MQTT?

Define aliases in autoexec.bat that map short command names to script start and stop actions. 1. Save the blinking logic as a simple looping script in the LittleFS panel. 2. Add aliases in autoexec.bat for starting and stopping that script. 3. Publish the alias command over MQTT from Home Assistant. The thread shows this exact pattern for a pseudo-animation that waits, changes brightness, waits again, and loops. [#20819967]

Why might a Home Assistant MQTT button appear on the dashboard but not trigger any action on the OBK device?

The button can appear correctly even when the MQTT command is wrong. In this thread, failure points include using the wrong topic, sending the wrong command name, or publishing before verifying that OpenBeken actually receives and processes the message. A practical check is to dry-test the publish in the OpenBeken MQTT HA tab and then inspect the OpenBeken log for received publications on the listened topic. [#20819967]

What are qos and retain in Home Assistant MQTT publish, and when should I change them from the defaults?

In this example, you can leave both at the defaults unless you need different broker behavior. The thread’s working button uses qos: 0 and retain: false, and the author explicitly says those settings were left unchanged. For a simple tap-to-trigger action such as slow_blink, the demonstrated setup worked without altering either field, so change them only if your own MQTT design requires it. [#20819967]

How can I use Home Assistant scripted buttons to launch lighting scenes like slow blink, work mode, or relaxation mode?

Create one button per scene and have each button publish a different MQTT command. The thread’s sample button starts a slow blink LED animation, and the summary suggests extending the same pattern to other lighting scenarios, such as work with cold white or relaxation with warm white. You can also create a separate button that stops the animation or switches the room into another predefined mode. [#20819967]

Tasmota vs OpenBeken for MQTT-controlled automations from Home Assistant — which is better for scriptable buttons and group commands?

Both fit dashboard-triggered MQTT buttons, but OpenBeken is shown more deeply in this thread. Tasmota and OpenBeken are both described as supporting separate device topics and shared group topics, so either can work for one-button multi-device control. OpenBeken gets the stronger practical example because the thread shows its group topic, LittleFS script, aliases in autoexec.bat, and log-based verification, while Tasmota is referenced mainly as compatible. [#20819967]

What is LittleFS in OpenBeken, and how is it used to store simple automation scripts or LED animations?

LittleFS is where the thread stores the device-side script that performs the LED animation. "LittleFS" is a file-system component that stores small scripts on the device, letting OpenBeken run local automation logic such as timed LED brightness loops. In the example, the script waits, changes brightness, waits again, and repeats, while Home Assistant only needs to trigger it over MQTT. [#20819967]

How can I build a Home Assistant button that turns off all lights in a room or prepares the room before I get home?

Use the same button pattern, but publish a command or trigger an automation for that room scenario. The thread explicitly says these buttons can launch selected scenarios, including turning off all house lights or preparing a room before return by turning on heating and lights. The key design is one dashboard button per scenario, with the real action executed by the target automation or MQTT listener. [#20819967]

What functions do other users assign to scriptable buttons on the Home Assistant panel, such as boiler control or room automation?

Users assign both heating and room-control tasks to scripted buttons and MQTT automations. The main post proposes scene buttons for lighting, all-lights-off actions, and room-preparation modes. A second user gives a concrete heating example: scripted MQTT-based control of a Vaillant boiler through ebusd, plus automation that fires every 1 minute to read current furnace settings and send MQTT commands. [#20820556]

How can MQTT automations in Home Assistant be used to control a Vaillant boiler through ebusd and periodically read current furnace settings?

Use MQTT commands for control and run a timed automation for status polling. The thread’s boiler example uses a Vaillant stove with the ebusd daemon listening for MQTT commands, so Home Assistant can send control messages through that path. The same user also runs an automation every 1 minute to read the current furnace settings, which means MQTT is used for both active control and recurring telemetry reads. [#20820556]
Generated by the language model.
ADVERTISEMENT