Add priority to on_shutdown trigger. (#2189)

This commit is contained in:
RoboMagus 2022-08-10 03:10:53 +02:00 committed by GitHub
parent 475933a41f
commit 72b7346128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,17 +115,26 @@ too many WiFi/MQTT connection attempts, Over-The-Air updates being applied or th
.. note::
It's not guaranteed that all components are in a connected state when this automation is triggered. For
example, the MQTT client may have already disconnected.
example, the MQTT client may have already disconnected. For use-cases that require specific shutdown ordering, look at the ``priority`` parameter.
.. code-block:: yaml
esphome:
# ...
on_shutdown:
priority: 700
then:
- switch.turn_off: switch_1
Configuration variables: See :ref:`Automation <automation>`.
Configuration variables:
- **priority** (*Optional*, float): The priority to execute your custom shutdown code. A higher value
means a high priority and in case of shutdown triggers that the code is executed **later**.
Priority is used primarily for the initialization order of components. Shutdowns for these components are handled in *reverse* order, such that e.g. sensors (600) are shutdown before the hardware components (800) they depend on.
Please note this is an ESPHome-internal value and any change will not be marked as a breaking change.
Defaults to ``600``. For priority values refer to the list in the :ref:`esphome-on_boot` section.
- See :ref:`Automation <automation>`.
.. _esphome-on_loop: