You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The state may also be invalidated by an API call in a lambda - see the API reference linked below.
103
+
104
+
82
105
Binary Sensor Filters
83
106
---------------------
84
107
@@ -274,7 +297,8 @@ Configuration variables: See :ref:`Automation <automation>`.
274
297
275
298
This automation will be triggered when a new state is received (and thus combines ``on_press``
276
299
and ``on_release`` into one trigger). The new state will be given as the variable ``x`` as a boolean
277
-
and can be used in :ref:`lambdas <config-lambda>`.
300
+
and can be used in :ref:`lambdas <config-lambda>`. It will not be called when the state is invalidated; it will be called when
301
+
the state initially becomes valid only if ``trigger_on_initial_state`` is true.
278
302
279
303
.. code-block:: yaml
280
304
@@ -287,6 +311,31 @@ and can be used in :ref:`lambdas <config-lambda>`.
287
311
288
312
Configuration variables: See :ref:`Automation <automation>`.
289
313
314
+
.. _binary_sensor-on_state_change:
315
+
316
+
``on_state_change``
317
+
*******************
318
+
319
+
An alternative to ``on_state`` that is also triggered when the binary sensor state is invalidated. It is passed two parameters, ``x`` as for ``on_change``
320
+
will be the new value, and ``x_previous`` is the value immediately prior to the change. Both these parameters are of type ``optional<bool>`` so also indicate
321
+
if the values were valid. Note that this is called on all state changes, including initial states.
0 commit comments