@@ -774,15 +774,16 @@ on that topic. Multiple ``@mqtt_trigger`` decorators can be applied to a single
774
774
to trigger off different mqtt topics.
775
775
776
776
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
778
778
variables:
779
779
780
780
- ``trigger_type `` is set to "mqtt"
781
781
- ``topic `` is set to the topic the message was received on
782
+ - ``qos `` is set to the message QoS.
782
783
- ``payload `` is set to the string payload of the message
783
784
- ``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 .
786
787
787
788
When the ``@mqtt_trigger `` occurs, those same variables are passed as keyword arguments to the
788
789
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
792
793
the message arrived on.
793
794
794
795
Wildcards are:
796
+
795
797
- ``+ `` matches a single level in the topic hierarchy.
796
798
- ``# `` matches zero or more levels in the topic hierarchy, can only be last.
797
799
@@ -2144,7 +2146,8 @@ it doesn't faithfully mimic Python. Here are some areas where pyscript differs
2144
2146
won't be able to call that pyscript function unless it uses ``await ``, which requires that function to
2145
2147
be declared ``async ``. Unless the Python module is designed to support async callbacks, it is not
2146
2148
currently possible to have Python modules and packages call pyscript functions. The workaround is
2147
- to move your callbacks from pyscript and make them native Python functions; see `Importing <#importing >`__.
2149
+ to move your callbacks from pyscript and make them native Python functions; see `Importing <#importing >`__,
2150
+ call a function with the ``@pyscript_compile `` decorator, or a lambda (which is also compiled).
2148
2151
- Continuing that point, special methods (e.g., ``__eq__ ``) in a class created in `pyscript ` will not work since
2149
2152
they are async functions and Python will not be able to call them. The two workarounds are to
2150
2153
use the ``@pyscript_compile `` decorator so the method is compiled to a native (non-async) Python
0 commit comments