I am trying to create an MQTT device trigger per the instructions here:
Here is my registration JSON payload that sets up the trigger:
{
"t": "cmd/test/primary",
"type": "button_short_press",
"stype": "turn_on",
"device": {
"ids": "TestId",
"name": "Test Device",
"mf": "Test Man",
"mdl": "Test Model",
"hw": "1.0",
"sw": "1.0",
"sa": "Somewhere",
"sn": "TODO1234"
},
"pl": "pushed",
"atype": "trigger",
"p": "device_automation"
}
However I am running into an issue that Home Assistant appears to send a fake “press” event whenever a the trigger is auto-discovered / registered.
I have been able to work around the issue by changing the payload from: “press” → “pushed”. Hence I can filter out the annoying “press” event by adding a condition, as follows:
alias: Trigger Test
description: ""
triggers:
- domain: mqtt
device_id: 5d4b5d319a572db91de47564dd056b1a
type: button_short_press
subtype: turn_on
metadata: {}
trigger: device
conditions:
- condition: template
value_template: "{{ trigger.payload == 'pushed' }}"
actions:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 100
target:
device_id: 6d5f3d7db5ca35664899489df309c38f
mode: single
Although the configuration above works, it feels like I have missed something.
Is there a simpler way to configure “momentary” buttons, i.e. buttons that don’t have a state like normal On/Off switches?