ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
4#include "media_player.h"
5
7
12 void operator()(MediaPlayerState /*state*/) const { this->automation->trigger(); }
13};
14
17template<MediaPlayerState State> struct StateEnterForwarder {
20 if (state == State)
21 this->automation->trigger();
22 }
23};
24
25static_assert(sizeof(StateAnyForwarder) <= sizeof(void *));
26static_assert(std::is_trivially_copyable_v<StateAnyForwarder>);
27static_assert(sizeof(StateEnterForwarder<MediaPlayerState::MEDIA_PLAYER_STATE_IDLE>) <= sizeof(void *));
28static_assert(std::is_trivially_copyable_v<StateEnterForwarder<MediaPlayerState::MEDIA_PLAYER_STATE_IDLE>>);
29
30} // namespace esphome::media_player
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:745
bool state
Definition fan.h:2
Callback forwarder that triggers an Automation<> on any state change.
Definition automation.h:10
void operator()(MediaPlayerState) const
Definition automation.h:12
Callback forwarder that triggers an Automation<> only when a specific media player state is entered.
Definition automation.h:17
void operator()(MediaPlayerState state) const
Definition automation.h:19