From db09f74cafc4c7d8e35fb7746d14b515156076ce Mon Sep 17 00:00:00 2001 From: Anthony Uk <1492471+dataway@users.noreply.github.com> Date: Wed, 19 May 2021 06:12:59 +0200 Subject: [PATCH] Add triggers on_turn_on / on_turn_off (#1116) --- components/fan/index.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/fan/index.rst b/components/fan/index.rst index 478e9d616..0b5f71ef5 100644 --- a/components/fan/index.rst +++ b/components/fan/index.rst @@ -45,6 +45,13 @@ MQTT options: speed commands on. - All other options from :ref:`MQTT Component `. +Automation triggers: + +- **on_turn_on** (*Optional*, :ref:`Action `): An automation to perform + when the fan is turned on. See :ref:`fan-on_turn_on_off_trigger`. +- **on_turn_off** (*Optional*, :ref:`Action `): An automation to perform + when the fan is turned off. See :ref:`fan-on_turn_on_off_trigger`. + .. _fan-toggle_action: ``fan.toggle`` Action @@ -95,6 +102,24 @@ Configuration options: - **speed** (*Optional*, int, :ref:`templatable `): Set the speed level of the fan. Can be a number between 1 and the maximum speed level of the fan. +.. _fan-on_turn_on_off_trigger: + +``fan.on_turn_on`` / ``fan.on_turn_off`` Trigger +**************************************************** + +This trigger is activated each time the fan is turned on or off. It does not fire +if a command to turn the fan on or off already matches the current state. + +.. code-block:: yaml + + fan: + - platform: speed # or any other platform + # ... + on_turn_on: + - logger.log: "Fan Turned On!" + on_turn_off: + - logger.log: "Fan Turned Off!" + Full Fan Index --------------