Homeassistant.event Action

I have button on esphome that send homeassistant.event` when i press the button.

How shall I write the automation in home assistant?
eg.

on_...
  # Simple
  - homeassistant.event:
      event: esphome.button_pressed
      data:
        message: "Button1 singel"

Thanks. Will test.
Then I need one automation for each button4, singel, dubbel & long press…
4
3= 12 automation.
Is it other way to build this smarter?
I have test controllex but I can´t get events working in controllex…
Then I have try to build one automation for all 12 function…
But nead help with this…

We will need more information to be able to help. You want to make an automation in HA to process the 12 possible incoming events? What are these events, and what do you want the automation to do?

Or are you asking for help with ESPHome?

More ask for help in Home assistant. Maby is wrong forum…

All 12 events config in esphome device as

          - homeassistant.event:
              event: esphome.button_pressed
              data:
                title: buttonXshortclick 
<..>
                title: buttonXlongclick 
<..>
               title: buttonXdoubleclick

*4

All buttonXshortclick shall only toggle different lights.
All buttonXdoubleclick shall trigger different scrips
All buttonXlongclick shall start dim on different lights, 10% down…

The esphome is

You’re in the right forum: just wanted to check.

Starting with 12 automations would be easiest. Then we can consider combining them depending on complexity. Here’s the first:

trigger:
  - platform: event
    event_type: esphome.button_pressed
    event_data:
      title: button1shortclick
action:
  - service: light.toggle
    entity_id: light.YOUR_LIGHT_ENTITY

Alternatively, you can combine the simple toggle ones — this uses the trigger ID to specify the light to be toggled for each button (just showing two for now):

trigger:
  - platform: event
    id: my_light_1
    event_type: esphome.button_pressed
    event_data:
      title: button1shortclick
  - platform: event
    id: my_light_2
    event_type: esphome.button_pressed
    event_data:
      title: button2shortclick
action:
  - service: light.toggle
    entity_id: light.{{ trigger.id }}

Yes…This was I look for…
Thanks!!!
Is working like glove!

1 Like