mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 17:05:34 +01:00
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com> Co-authored-by: abmantis <amfcalt@gmail.com> Co-authored-by: Bram Kragten <mail@bramkragten.nl> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
29 lines
794 B
Python
29 lines
794 B
Python
"""Provides triggers for media players."""
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.trigger import Trigger, make_conditional_entity_state_trigger
|
|
|
|
from . import MediaPlayerState
|
|
from .const import DOMAIN
|
|
|
|
TRIGGERS: dict[str, type[Trigger]] = {
|
|
"stopped_playing": make_conditional_entity_state_trigger(
|
|
DOMAIN,
|
|
from_states={
|
|
MediaPlayerState.BUFFERING,
|
|
MediaPlayerState.PAUSED,
|
|
MediaPlayerState.PLAYING,
|
|
},
|
|
to_states={
|
|
MediaPlayerState.IDLE,
|
|
MediaPlayerState.OFF,
|
|
MediaPlayerState.ON,
|
|
},
|
|
),
|
|
}
|
|
|
|
|
|
async def async_get_triggers(hass: HomeAssistant) -> dict[str, type[Trigger]]:
|
|
"""Return the triggers for media players."""
|
|
return TRIGGERS
|