Request: Payload key parser in MQTT-trigger


#1

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.


#2

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
  trigger:
    platform: mqtt
    topic: test/sensor/state
  condition:
    condition: template
    value_template: '{{ trigger.payload_json.gadget[0].temperature > 18 }}'
  action:
    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?


#3

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"

#4

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?