Cannot create Automation trigger on an Event that shows up in a Shelly device page

Not sure if this is a front end issue, a configuration issue or a Shelly Integration issue as I am new to HA and do not know how to investigate baffling issues like this, which seems to be some kind of naming conflict.

I’m working on the control panel that comes up when I click on a Shelly device in the Devices tab of the Shelly Integration list. In the ‘Events’ pane, I have two entries ‘Button1’ and ‘Button3’ and when I press the appropriate buttons on the device these events show appropriately (‘Single push’, ‘Double push’ etc.) in HA. If I create an Automation based on a ‘Button1’ trigger, everything works as expected (although the drop-down list in the visual editor unhelpfully shows it as ‘First button’ rather than ‘Button1’). But the drop-down list does not show ‘Second button’ or ‘Third button’, just ‘Button101’. If I select that, when I save the Automation I get an error message:

Message malformed: value must be one of ['button', 'button1', 'button2', 'button3', 'button4', 'button5'] for dictionary value @ data['subtype']

I went in to the YAML editor and changed ‘button101’ to each of the suggested valid values in turn. Except for ‘button1’, all the values gave the same error message. I can change the name of these components in the Shelly web page for the device, so I tried changing it to ‘button101’. This change propagated automatically to HA and the events continued to be shown as expected, but attempts to trigger an Automation on ‘button101’ still gave the same error message.

I do not think this is a problem with the Shelly device as the Events are showing as expected within HA, but for background it is a Shelly 1 PM Gen4 with the Shelly Plus add on. The button that works in HA is connected to the main device while the one that does not work is connected to the digital input on the Shelly Plus. Both are configured as Buttons (rather than Switches) and ‘detached’.

Can you share your automation YAML?

Typically in the UI you can use button presses as triggers from the ‘Device’ option, there’s then a drop down for the different buttons.

Failing that, have a look in Developer Tools > States for the button you’re interested in. You can then trigger based on a change to that entity.

1 Like

The Developer Tools > States entry for the button is:

event_types: single_push, btn_up, triple_push, double_push, long_push, btn_down
event_type: single_push
device_class: button
friendly_name: Study Room Controller button101

The YAML for the Automation that triggers the error message is:

device_id: 1e71f3697eea4d05cb70a39f637f6e11
domain: shelly
type: single_push
subtype: button101
metadata: {}
trigger: device

I cannot show the full YAML for this automation because the error message prevents it saving, but here is one for the other button:

id: '1766748822484'
  alias: Study Desk Light Toggle
  description: ''
  triggers:
  - device_id: 1e71f3697eea4d05cb70a39f637f6e11
    domain: shelly
    type: double_push
    subtype: button1
    trigger: device
  conditions: []
  actions:
  - action: light.toggle
    metadata: {}
    target:
      entity_id: light.studydesklights
    data: {}
  mode: single

I have tried editing the ‘subtype:’ field in the trigger YAML to each of the values the error message says would be OK, but the only one that does not trigger an error message is ‘button1’.

As reported before, e.g. ‘button101’ gives the following error:

Message malformed: value must be one of ['button', 'button1', 'button2', 'button3', 'button4', 'button5'] for dictionary value @ data['subtype']

While names in the list (e.g. ‘button3’, except ‘button1’) give the following error:

Message malformed: Invalid device automation trigger (type, subtype): ('single_push', 'button3')

Let’s get the basics out of the way. Is your Shelly a Gen4 integrated into HA via zigbee mode? If yes, then the addon won’t work (read here)

If not, then you might still have a shot at automating the button press via the addon. go to Dev Tools > Events > put * in the “Event to subscribe to” field > Start Listening > double press button > immediately press "Stop Listening to avoid spam.

You should be able to set up an automation based on that event if you use an Event trigger.

Thanks for offering help.

The device is a Gen4 relay (1PM) running the Matter firmware (non-Zigbee) but communicating over WiFi with the Shelly Integration in HA (so presumably using native RPCs, not Matter).

I tried the suggested Event listener. I think this is the relevant event:

event_type: shelly.click
data:
  device_id: 1e71f3697eea4d05cb70a39f637f6e11
  device: shelly1pmg4-a085e3bd22b4
  channel: 101
  click_type: single_push
  generation: 2
origin: LOCAL
time_fired: "2025-12-29T22:01:47.285849+00:00"
context:
  id: 01KDP23DGN6N2Y6WD9S7KWS34V
  parent_id: null
  user_id: null

But my puzzle is how the the fields in this and the trigger YAML in the post above (which was generated by the UI) correlate and why the UI generated YAML gives an error when saved. Also where does the list of valid subtypes the save is validating against come from?

Comparing this to the button that works, it’s event comes through like this:

event_type: shelly.click
data:
  device_id: 1e71f3697eea4d05cb70a39f637f6e11
  device: shelly1pmg4-a085e3bd22b4
  channel: 1
  click_type: single_push
  generation: 2
origin: LOCAL
time_fired: "2025-12-29T22:29:57.678604+00:00"
context:
  id: 01KDP3Q09E202EFCERRGPTG9PN
  parent_id: null
  user_id: null

This event correctly fires the Automation listed in my previous post ‘Study Desk Light Toggle’.

You were using a device trigger when the automation gave you the error. You need to use an event trigger instead.

The trigger will probably only need the first few lines of the event. Anything from origin till the end can be left out:

trigger: event
event_type: shelly.click
event_data:
  device_id: 1e71f3697eea4d05cb70a39f637f6e11
  device: shelly1pmg4-a085e3bd22b4
  channel: 101
  click_type: single_push
  generation: 2

Many thanks for this, it does provide a usable work-around.

I am still very puzzled why the original approach, the ‘device trigger’, (which is very much what the UI guides one to) worked for ‘button1’, but failed for ‘button101’ when the only difference between the two seems to be the ‘channel’ number. The ‘event trigger’ approach is very much more technical since the UI for it is basically just a free-form YAML text editor.

Would I be right in assuming this is a bug either in the integration or the core? It seems very wrong to me that a UI would generate YAML from drop-down selections that subsequently fails verification. The data driving the verification and that driving the selection lists in the UI should surely be the same?