Skip to content

Commit

Permalink
Merge pull request #677 from larsimmisch/larsimmisch/mqtt-docs
Browse files Browse the repository at this point in the history
Document @mqtt_trigger wildcards, add an example
  • Loading branch information
craigbarratt authored Jan 12, 2025
2 parents ed6b459 + 916b686 commit 37aad44
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.home-assistant.io/integrations/mqtt/>`__
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
^^^^^^^^^^^^^

Expand Down

0 comments on commit 37aad44

Please sign in to comment.