From a17f53cf44f0b88fcc7f4968920ae26bd54e4648 Mon Sep 17 00:00:00 2001 From: rwrozelle Date: Thu, 3 Jul 2025 06:55:45 -0400 Subject: [PATCH 1/3] Add turn_off and turn_on to media_player --- components/media_player/index.rst | 76 +++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/components/media_player/index.rst b/components/media_player/index.rst index b93b2f563a..012c49f354 100644 --- a/components/media_player/index.rst +++ b/components/media_player/index.rst @@ -53,6 +53,8 @@ Media Player Actions All ``media_player`` actions can be used without specifying an ``id`` if you have only one ``media_player`` in your configuration YAML. +The new actions ``turn_off`` and ``turn_on`` are optional and based on the platform implementing the ``supports_turn_off_on`` trait. + Configuration variables: **id** (*Optional*, :ref:`config-id`): The media player to control. Defaults to the only one in YAML. @@ -115,6 +117,20 @@ Configuration variables: This action will pause or resume the current playback. +.. _media_player-turn_off: + +``media_player.turn_off`` Action +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This action will turn off the media player. + +.. _media_player-turn_on: + +``media_player.turn_on`` Action +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This action will turn on the media player. + .. _media_player-volume_up: ``media_player.volume_up`` Action @@ -230,6 +246,36 @@ This trigger is activated every time the media player plays an announcement. on_announcement: - logger.log: "Announcing!" +.. _media_player-on_turn_off_trigger: + +``media_player.on_turn_off`` Trigger +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This trigger is activated every time the media player is turned off. + +.. code-block:: yaml + + media_player: + - platform: tbd # any platform implementing the ``supports_turn_off_on`` trait + # ... + on_turn_off: + - logger.log: "Media Player is Turned Off" + +.. _media_player-on_turn_on_trigger: + +``media_player.on_turn_on`` Trigger +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This trigger is activated every time the media player is turned on. + +.. code-block:: yaml + + media_player: + - platform: tbd # any platform implementing the ``supports_turn_off_on`` trait + # ... + on_turn_on: + - logger.log: "Media Player is Turned On" + .. _media_player-is_idle_condition: ``media_player.is_idle`` Condition @@ -290,6 +336,36 @@ This condition checks if the media player is playing an announcement. condition: media_player.is_announcing: +.. _media_player-is_off_condition: + +``media_player.is_off`` Condition +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This condition checks if the media player is turned off. + +.. code-block:: yaml + + # In some trigger: + on_...: + if: + condition: + media_player.is_off: + +.. _media_player-is_on_condition: + +``media_player.is_on`` Condition +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This condition checks if the media player is turned on. + +.. code-block:: yaml + + # In some trigger: + on_...: + if: + condition: + media_player.is_on: + Play media in order ------------------- From 46843d85a66ffebdd704c52e9c82f4af7546d70f Mon Sep 17 00:00:00 2001 From: rwrozelle Date: Thu, 3 Jul 2025 07:06:52 -0400 Subject: [PATCH 2/3] fix underline --- components/media_player/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/media_player/index.rst b/components/media_player/index.rst index 012c49f354..b7daa231f1 100644 --- a/components/media_player/index.rst +++ b/components/media_player/index.rst @@ -120,14 +120,14 @@ This action will pause or resume the current playback. .. _media_player-turn_off: ``media_player.turn_off`` Action -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This action will turn off the media player. .. _media_player-turn_on: ``media_player.turn_on`` Action -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This action will turn on the media player. From 3de1771de0fec1263f19a4b2c7b6248f70b7162c Mon Sep 17 00:00:00 2001 From: rwrozelle Date: Thu, 3 Jul 2025 07:10:31 -0400 Subject: [PATCH 3/3] fix additional underlines --- components/media_player/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/media_player/index.rst b/components/media_player/index.rst index b7daa231f1..167f9c3eae 100644 --- a/components/media_player/index.rst +++ b/components/media_player/index.rst @@ -249,7 +249,7 @@ This trigger is activated every time the media player plays an announcement. .. _media_player-on_turn_off_trigger: ``media_player.on_turn_off`` Trigger -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This trigger is activated every time the media player is turned off. @@ -264,7 +264,7 @@ This trigger is activated every time the media player is turned off. .. _media_player-on_turn_on_trigger: ``media_player.on_turn_on`` Trigger -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This trigger is activated every time the media player is turned on. @@ -339,7 +339,7 @@ This condition checks if the media player is playing an announcement. .. _media_player-is_off_condition: ``media_player.is_off`` Condition -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This condition checks if the media player is turned off. @@ -354,7 +354,7 @@ This condition checks if the media player is turned off. .. _media_player-is_on_condition: ``media_player.is_on`` Condition -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This condition checks if the media player is turned on.