Skip to content

Commit d4e4915

Browse files
rwrozellebdraco
andauthored
media_player add off on capability (#5059)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent a38078d commit d4e4915

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

components/media_player/index.rst

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Media Player Actions
5353
All ``media_player`` actions can be used without specifying an ``id`` if you have only one ``media_player`` in
5454
your configuration YAML.
5555

56+
The actions ``turn_off`` and ``turn_on`` are optional and based on the platform implementing the ``supports_turn_off_on`` trait.
57+
5658
Configuration variables:
5759

5860
**id** (*Optional*, :ref:`config-id`): The media player to control. Defaults to the only one in YAML.
@@ -115,6 +117,20 @@ Configuration variables:
115117

116118
This action will pause or resume the current playback.
117119

120+
.. _media_player-turn_off:
121+
122+
``media_player.turn_off`` Action
123+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124+
125+
This action will turn off the media player.
126+
127+
.. _media_player-turn_on:
128+
129+
``media_player.turn_on`` Action
130+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131+
132+
This action will turn on the media player.
133+
118134
.. _media_player-volume_up:
119135

120136
``media_player.volume_up`` Action
@@ -230,6 +246,36 @@ This trigger is activated every time the media player plays an announcement.
230246
on_announcement:
231247
- logger.log: "Announcing!"
232248
249+
.. _media_player-on_turn_off_trigger:
250+
251+
``media_player.on_turn_off`` Trigger
252+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
253+
254+
This trigger is activated every time the media player is turned off.
255+
256+
.. code-block:: yaml
257+
258+
media_player:
259+
- platform: ... # any platform implementing the ``supports_turn_off_on`` trait
260+
# ...
261+
on_turn_off:
262+
- logger.log: "Media Player is Turned Off"
263+
264+
.. _media_player-on_turn_on_trigger:
265+
266+
``media_player.on_turn_on`` Trigger
267+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
268+
269+
This trigger is activated every time the media player is turned on.
270+
271+
.. code-block:: yaml
272+
273+
media_player:
274+
- platform: ... # any platform implementing the ``supports_turn_off_on`` trait
275+
# ...
276+
on_turn_on:
277+
- logger.log: "Media Player is Turned On"
278+
233279
.. _media_player-is_idle_condition:
234280

235281
``media_player.is_idle`` Condition
@@ -290,6 +336,36 @@ This condition checks if the media player is playing an announcement.
290336
condition:
291337
media_player.is_announcing:
292338
339+
.. _media_player-is_off_condition:
340+
341+
``media_player.is_off`` Condition
342+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
343+
344+
This condition checks if the media player is turned off.
345+
346+
.. code-block:: yaml
347+
348+
# In some trigger:
349+
on_...:
350+
if:
351+
condition:
352+
media_player.is_off:
353+
354+
.. _media_player-is_on_condition:
355+
356+
``media_player.is_on`` Condition
357+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
358+
359+
This condition checks if the media player is turned on.
360+
361+
.. code-block:: yaml
362+
363+
# In some trigger:
364+
on_...:
365+
if:
366+
condition:
367+
media_player.is_on:
368+
293369
Play media in order
294370
-------------------
295371

0 commit comments

Comments
 (0)