Add PN532 On Tag Trigger (#57)

This commit is contained in:
Otto Winter 2018-10-17 21:03:09 +02:00 committed by GitHub
parent a15e0b176f
commit 8241cacf60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -42,6 +42,8 @@ Configuration variables:
- **update_interval** (*Optional*, :ref:`config-time`): The duration of each scan on the PN532. This affects the - **update_interval** (*Optional*, :ref:`config-time`): The duration of each scan on the PN532. This affects the
duration that the individual binary sensors stay active when they're found. duration that the individual binary sensors stay active when they're found.
If a device is not found within this time window, it will be marked as not present. Defaults to 1s. If a device is not found within this time window, it will be marked as not present. Defaults to 1s.
- **on_tag** (*Optional*, :ref:`Automation <automation>`): An automation to perform
when a tag is read. See :ref:`pn532-on_tag`.
- **spi_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`SPI Component <spi>` if you want - **spi_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the :ref:`SPI Component <spi>` if you want
to use multiple SPI buses. to use multiple SPI buses.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID for this component. - **id** (*Optional*, :ref:`config-id`): Manually specify the ID for this component.
@ -52,6 +54,28 @@ Configuration variables:
Example for hooking up the PN532 via SPI. Notice the position of the two switches on the right. Example for hooking up the PN532 via SPI. Notice the position of the two switches on the right.
.. _pn532-on_tag:
``on_tag``
----------
This automation will be triggered when the PN532 module responds with a tag. Please note that this
can be called quite often (with an interval of ``update_interval``) as it's triggered repeatedly
if the tag is re-read many times.
The parameter ``x`` this trigger provides is of type ``std::string`` and is the tag UID in the format
``74-10-37-94``. The configuration below will for example publish the tag ID on the MQTT topic ``pn532/tag``.
.. code:: yaml
pn532:
# ...
on_tag:
then:
- mqtt.publish:
topic: pn532/tag
payload: !lambda 'return x;'
See Also See Also
-------- --------

View File

@ -303,6 +303,7 @@ All Triggers
- :ref:`esphomeyaml.on_boot <esphomeyaml-on_boot>` - :ref:`esphomeyaml.on_boot <esphomeyaml-on_boot>`
- :ref:`esphomeyaml.on_shutdown <esphomeyaml-on_shutdown>` - :ref:`esphomeyaml.on_shutdown <esphomeyaml-on_shutdown>`
- :ref:`esphomeyaml.on_loop <esphomeyaml-on_loop>` - :ref:`esphomeyaml.on_loop <esphomeyaml-on_loop>`
- :ref:`pn532.on_tag <pn532-on_tag>`
All Actions All Actions
----------- -----------