#pragma once

#include "esphome/core/automation.h"
#include "mixer_speaker.h"

#ifdef USE_ESP32

namespace esphome::mixer_speaker {
template<typename... Ts> class DuckingApplyAction final : public Action<Ts...>, public Parented<SourceSpeaker> {
  TEMPLATABLE_VALUE(uint8_t, decibel_reduction);
  TEMPLATABLE_VALUE(uint32_t, duration);
  void play(const Ts &...x) override {
    this->parent_->apply_ducking(this->decibel_reduction_.value(x...), this->duration_.value(x...));
  }
};
}  // namespace esphome::mixer_speaker

#endif
