Request: Payload key parser in MQTT-trigger


It would be nice to extend the “payload” parameter functionality for MQTT trigger, to have the ability to filter trigger on a per-key basis. For now, it’s necessary to use the following “condition” statement for a multi-key payload which is pretty unhandy (and sometimes impossible) in case you trying to combine several triggers.


If I have sensor publishing its data as a complex JSON payload, I can currently trigger on a specific portion of the payload using a condition like this:

- alias: test_sensor
    platform: mqtt
    topic: test/sensor/state
    condition: template
    value_template: '{{ trigger.payload_json.gadget[0].temperature > 18 }}'
    service: switch.toggle
    entity_id: switch.pump

However, you stated you don’t want to use conditions. Can you give me an example of what the trigger section would look like using your proposed system?


Just like i said - key and value filters as trigger parameters (maybe instead of payload in this case), smth like this:

platform: mqtt
topic: some/topic
key: "key_name"
value: "key_value"


What advantage is there to specifying “key_value”, in a new option called value, within the trigger as opposed to within the condition’s value_template?