From 916b686aaf539292fee70340d80c7cfe0a0da1ad Mon Sep 17 00:00:00 2001 From: Lars Immisch Date: Sun, 12 Jan 2025 17:35:43 +0100 Subject: [PATCH] Document @mqtt_trigger wildcards, add an example --- docs/reference.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/reference.rst b/docs/reference.rst index e4e5beb..20393a3 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -791,9 +791,22 @@ optional ``kwargs`` argument to a ``dict`` with the keywords and values. Wildcards in topics are supported. The ``topic`` variables will be set to the full expanded topic the message arrived on. +Wildcards are: +- ``+`` matches a single level in the topic hierarchy. +- ``#`` matches zero or more levels in the topic hierarchy, can only be last. + NOTE: The `MQTT Integration in Home Assistant `__ must be set up to use ``@mqtt_trigger``. +.. code:: python + + @mqtt_trigger('zigbee2mqtt/carport/motion', "payload_obj['occupancy'] != None") + @time_active("range(sunset - 30m, sunrise - 30m)") + def carport_motion(): + light.turn_on(entity_id="light.carport") + task.sleep(300) + light.turn_off(entity_id="light.carport") + @state_active ^^^^^^^^^^^^^