Skip to content

Commit 25c9b5a

Browse files
authored
Update reference.rst @mqtt_trigger
It says four variables, but lists five, removed "four". I was tripped up by a null message with a payload_obj listed as a required function parameter, give a hint for not specifying it as a required parameter. Moved qos before payload as I listed the arguments in order, and needed it to not be last for payload_obj to be optional and qos not. Fixed the Wildcard formatting, the two bullet points were all made into one paragraph with "- + matches" confusing as I didn't think - was a wildcard, it needed the blank line to render them as bullet points.
1 parent 673a0a0 commit 25c9b5a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/reference.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,15 +774,16 @@ on that topic. Multiple ``@mqtt_trigger`` decorators can be applied to a single
774774
to trigger off different mqtt topics.
775775

776776
An optional ``str_expr`` can be used to match the MQTT message data, and the trigger will only occur
777-
if that expression evaluates to ``True`` or non-zero. This expression has available these four
777+
if that expression evaluates to ``True`` or non-zero. This expression has available these
778778
variables:
779779

780780
- ``trigger_type`` is set to "mqtt"
781781
- ``topic`` is set to the topic the message was received on
782+
- ``qos`` is set to the message QoS.
782783
- ``payload`` is set to the string payload of the message
783784
- ``payload_obj`` if the payload was valid JSON, this will be set to the native Python object
784-
representing that payload.
785-
- ``qos`` is set to the message QoS.
785+
representing that payload. A null message will not be converted. If payload_obj is a
786+
required function argument an exception will be thrown, use payload_obj=None.
786787

787788
When the ``@mqtt_trigger`` occurs, those same variables are passed as keyword arguments to the
788789
function in case it needs them. Additional keyword parameters can be specified by setting the
@@ -792,6 +793,7 @@ Wildcards in topics are supported. The ``topic`` variables will be set to the fu
792793
the message arrived on.
793794

794795
Wildcards are:
796+
795797
- ``+`` matches a single level in the topic hierarchy.
796798
- ``#`` matches zero or more levels in the topic hierarchy, can only be last.
797799

0 commit comments

Comments
 (0)