Skip to content

media_player add off on capability #5059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions components/media_player/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
-------------------

Expand Down