Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4acb52e

Browse files
Merge pull request #755 from 3735943886/add_retain_flag_to_mqtt_trigger
Add retain flag to mqtt trigger
2 parents 7e54c83 + 9ae6555 commit 4acb52e

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

‎custom_components/pyscript/eval.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"payload",
7171
"payload_obj",
7272
"qos",
73+
"retain",
7374
"topic",
7475
"trigger_type",
7576
"trigger_time",

‎custom_components/pyscript/mqtt.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def mqtt_message_handler(mqttmsg):
4545
"topic": mqttmsg.topic,
4646
"payload": mqttmsg.payload,
4747
"qos": mqttmsg.qos,
48+
"retain": mqttmsg.retain,
4849
}
4950

5051
try:

‎docs/reference.rst‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,14 @@ An optional ``str_expr`` can be used to match the MQTT message data, and the tri
778778
if that expression evaluates to ``True`` or non-zero. This expression has available these
779779
variables:
780780

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

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /