Automation MQTT Trigger (with payload) - Sonoff Tasmota

Hi!

Anyone knows how to use that “payload” option from MQTT trigger in an automation?
I use a tasmotized sonoff and this is what I receive through the mqtt

Message 1 received on tele/ZigBee_Bridge/AACC/SENSOR at 23:45:

{"ZbReceived":{"Bathroom_Ambient":{"Device":"0xAACC","Name":"Bathroom_Ambient","EF00/0213":492,"Endpoint":1,"LinkQuality":66}}}

I want to make an automation which triggers when the tele/ZigBee_Bridge/AACC/SENSOR topic is received with a payload which contains this EF00/0213, but I don’t want to achieve this through a condition, I want to know how to use this optional feature of the trigger, called “payload”.

This is what I done till now, but it is not working…

alias: test
description: ""
trigger:
  - platform: mqtt
    topic: tele/ZigBee_Bridge/59C2/SENSOR
    payload: "['ZbReceived']['Bathroom_Ambient']['EF00/0213']"
condition: []
action:
  - service: persistent_notification.create
    data:
      message: Test
mode: single

Any help? Thanks in advance!

Payload has to be identical to the actual message received

alias: test
description: ""
trigger:
  - platform: mqtt
    topic: tele/ZigBee_Bridge/59C2/SENSOR
    payload: '{"ZbReceived":{"Bathroom_Ambient":{"Device":"0xAACC","Name":"Bathroom_Ambient","EF00/0213":492,"Endpoint":1,"LinkQuality":66}}}'
condition: []
action:
  - service: persistent_notification.create
    data:
      message: Test
mode: single

But that can be a problem if the linkquality changes.

In the linkquality and that value which I need "EF00/0213":492, this is the humidity value which is changing all the time…

And, there is no way to talk with this “payload” option in order to tell him that is ok to receive only a part of the payload? :smiley:

I need to use something from the trigger instead of condition because I can’t follow the traces anymore. The automation will trigger 20 times per minute, at least, and using a condition will make the “traces” option not usable, I need something to use it with trigger…

if it is a humidity sensor, why not create a mqtt sensor and base your automation on that sensor ?

Well… For this case, I think an automation will fitt me more, or at least, I don’t know if I know how to achieve the same result through a mqtt sensor.

Look, this is my autiomation which gets the data from the Zigbee Temperature sensor.

alias: MQTT2Var - Ambient - Bathroom Temperature
description: ""
trigger:
  - platform: mqtt
    topic: tele/ZigBee_Bridge/59C2/SENSOR
condition:
  - condition: template
    value_template: >-
      {{ 'EF00/0212' in trigger.payload_json['ZbReceived']['Bathroom_Ambient']
      }}
  - condition: template
    value_template: >-
      {{
      is_number(trigger.payload_json['ZbReceived']['Bathroom_Ambient']['EF00/0212']
      | multiply(0.1) | float | round(1)) }}
  - condition: or
    conditions:
      - condition: template
        value_template: >-
          {{ (states('variable.bathroom_ambient_temperature') | float -
          (trigger.payload_json['ZbReceived']['Bathroom_Ambient']['EF00/0212'] |
          multiply(0.1) | float | round(1) - 0.50)) | abs | round(1) >= 1 }}
      - condition: template
        value_template: >-
          {{ (as_timestamp(now()) -
          as_timestamp(states.variable.bathroom_ambient_temperature.last_changed))
          | int > 1800 }}
action:
  - service: variable.set_variable
    data:
      variable: bathroom_ambient_temperature
      value: |
        {{ trigger.payload_json['ZbReceived']['Bathroom_Ambient']['EF00/0212'] |
        multiply(0.1) | float | round(1) - 0.50 }}
  - service: variable.set_variable
    data:
      variable: bathroom_ambient_temperature
      attributes:
        string_state: |
          {% set var =
          trigger.payload_json['ZbReceived']['Bathroom_Ambient']['EF00/0212'] |
          multiply(0.1) | float | round(1) - 0.50 %}
          {% if var <= 13 %}very low
          {% elif 15 <= var <= 18 %}low
          {% elif 20 <= var <= 25 %}normal
          {% elif 27 <= var <= 30 %}high
          {% elif var >= 32 %}very high
          {% else %}
          {{ state_attr("variable.bathroom_ambient_temperature","string_state")
          }}
          {% endif %}
mode: single

This sensor, it is sending data to zigbee two times per second (if you can imagine)… so, my bridge it is full of data, but this is not the problem, it can handle it. This autiomation do some restrictions to the received data, like you can see already. Set the variable by one of two grand condition, if 30 minutes passed or if the temperature it is changed by 1%…

As I said, I don’t know if I know how to achieve the same result with a mqtt senor. I say this because I have not even tried or thinked to try :smiley:

But… as I requested initally, I don’t want my autiomation trigger 100 times per minute, because a condition, will still run the automation, but it will not pass the condition. A payload instead, being as an option inside the trigger, I will help more, but if it is working like you said, this is no help… :frowning: That payload option should have something like template, I don’t know… :frowning:

There is a simple solution. I tried it myself recently when I encountered the same problem.

  • id: “15726685”
    alias: MQTT
    description: MQTT
    initial_state: true

    trigger:

    • platform: mqtt
      topic: zigbee2mqtt/Cube
      payload: “slide”
      value_template: “{{value_json.action}}”
      id: slide
    • platform: mqtt
      topic: zigbee2mqtt/Cube
      payload: “flip90”
      value_template: “{{value_json.action}}”
      id: flip
      condition:
      action:
    • choose:
      • conditions:
        • condition: trigger
          id: slide

I hope this will be useful. Good luck ::