mirror of
https://github.com/esphome/esphome-docs.git
synced 2025-03-31 17:45:57 +02:00
Add docs for mqtt.on_connect / on_disconnect (#2105)
This commit is contained in:
parent
2b3edea033
commit
c34c62430d
@ -89,6 +89,10 @@ Configuration variables:
|
||||
- **keepalive** (*Optional*, :ref:`config-time`): The time
|
||||
to keep the MQTT socket alive, decreasing this can help with overall stability due to more
|
||||
WiFi traffic with more pings. Defaults to 15 seconds.
|
||||
- **on_connect** (*Optional*, :ref:`Automation <automation>`): An action to be performed when a connection
|
||||
to the broker is established.
|
||||
- **on_disconnect** (*Optional*, :ref:`Automation <automation>`): An action to be performed when the connection
|
||||
to the broker is dropped.
|
||||
- **on_message** (*Optional*, :ref:`Automation <automation>`): An action to be
|
||||
performed when a message on a specific MQTT topic is received. See :ref:`mqtt-on_message`.
|
||||
- **on_json_message** (*Optional*, :ref:`Automation <automation>`): An action to be
|
||||
@ -368,6 +372,22 @@ Configuration variables:
|
||||
When changing these options and you're using MQTT discovery, you will need to restart Home Assistant.
|
||||
This is because Home Assistant only discovers a device once in every Home Assistant start.
|
||||
|
||||
.. _mqtt-on_connect_disconnect:
|
||||
|
||||
``on_connect`` / ``on_disconnect`` Trigger
|
||||
------------------------------------------
|
||||
|
||||
This trigger is activated when a connection to the MQTT broker is established or dropped.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
mqtt:
|
||||
# ...
|
||||
on_connect:
|
||||
- switch.turn_on: switch1
|
||||
on_disconnect:
|
||||
- switch.turn_off: switch1
|
||||
|
||||
.. _mqtt-on_message:
|
||||
|
||||
``on_message`` Trigger
|
||||
|
@ -330,7 +330,8 @@ All Triggers
|
||||
- :ref:`light.on_turn_on / light.on_turn_off <light-on_turn_on_off_trigger>`
|
||||
- :ref:`logger.on_message <logger-on_message>`
|
||||
- :ref:`time.on_time <time-on_time>` / - :ref:`time.on_time_sync <time-on_time_sync>`
|
||||
- :ref:`mqtt.on_message <mqtt-on_message>` / :ref:`mqtt.on_json_message <mqtt-on_json_message>`
|
||||
- :ref:`mqtt.on_message <mqtt-on_message>` / :ref:`mqtt.on_json_message <mqtt-on_json_message>` /
|
||||
:ref:`mqtt.on_connect / mqtt.on_disconnect <mqtt-on_connect_disconnect>`
|
||||
- :ref:`pn532.on_tag <pn532-on_tag>` / :ref:`rdm6300.on_tag <rdm6300-on_tag>`
|
||||
- :ref:`interval.interval <interval>`
|
||||
- :ref:`switch.on_turn_on / switch.on_turn_off <switch-on_turn_on_off_trigger>`
|
||||
|
Loading…
Reference in New Issue
Block a user