Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions custom_components/pyscript/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"payload",
"payload_obj",
"qos",
"retain",
"topic",
"trigger_type",
"trigger_time",
Expand Down
1 change: 1 addition & 0 deletions custom_components/pyscript/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def mqtt_message_handler(mqttmsg):
"topic": mqttmsg.topic,
"payload": mqttmsg.payload,
"qos": mqttmsg.qos,
"retain": mqttmsg.retain,
}

try:
Expand Down
7 changes: 4 additions & 3 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,14 @@ An optional ``str_expr`` can be used to match the MQTT message data, and the tri
if that expression evaluates to ``True`` or non-zero. This expression has available these
variables:

- ``trigger_type`` is set to "mqtt"
- ``topic`` is set to the topic the message was received on
- ``trigger_type`` is set to "mqtt".
- ``topic`` is set to the topic the message was received on.
- ``qos`` is set to the message QoS.
- ``payload`` is set to the string payload of the message
- ``payload`` is set to the string payload of the message.
- ``payload_obj`` if the payload was valid JSON, this will be set to the native Python object
representing that payload. A null message will not be converted. If payload_obj is a
required function argument an exception will be thrown, use payload_obj=None.
- ``retain`` is set to the message retain flag. True if the message was retained, False otherwise.

When the ``@mqtt_trigger`` occurs, those same variables are passed as keyword arguments to the
function in case it needs them. Additional keyword parameters can be specified by setting the
Expand Down
Loading