Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document @mqtt_trigger wildcards, add an example #677

Merged
Merged
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
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
Loading