ESPHome 2025.5.0
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
4#include "microphone.h"
5
6#include <vector>
7
8namespace esphome {
9namespace microphone {
10
11template<typename... Ts> class CaptureAction : public Action<Ts...>, public Parented<Microphone> {
12 void play(Ts... x) override { this->parent_->start(); }
13};
14
15template<typename... Ts> class StopCaptureAction : public Action<Ts...>, public Parented<Microphone> {
16 void play(Ts... x) override { this->parent_->stop(); }
17};
18
19template<typename... Ts> class MuteAction : public Action<Ts...>, public Parented<Microphone> {
20 void play(Ts... x) override { this->parent_->set_mute_state(true); }
21};
22template<typename... Ts> class UnmuteAction : public Action<Ts...>, public Parented<Microphone> {
23 void play(Ts... x) override { this->parent_->set_mute_state(false); }
24};
25
26class DataTrigger : public Trigger<const std::vector<uint8_t> &> {
27 public:
28 explicit DataTrigger(Microphone *mic) {
29 mic->add_data_callback([this](const std::vector<uint8_t> &data) { this->trigger(data); });
30 }
31};
32
33template<typename... Ts> class IsCapturingCondition : public Condition<Ts...>, public Parented<Microphone> {
34 public:
35 bool check(Ts... x) override { return this->parent_->is_running(); }
36};
37
38template<typename... Ts> class IsMutedCondition : public Condition<Ts...>, public Parented<Microphone> {
39 public:
40 bool check(Ts... x) override { return this->parent_->get_mute_state(); }
41};
42
43} // namespace microphone
44} // namespace esphome
Base class for all automation conditions.
Definition automation.h:75
Helper class to easily give an object a parent of type T.
Definition helpers.h:538
void add_data_callback(std::function< void(const std::vector< uint8_t > &)> &&data_callback)
Definition microphone.cpp:6
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5