10static const char *
const TAG =
"infrared";
69 " Supports Transmitter: %s\n"
70 " Supports Receiver: %s",
79 ESP_LOGW(TAG,
"No transmitter configured");
83 if (!
call.has_raw_timings()) {
84 ESP_LOGE(TAG,
"No raw timings provided");
90 auto *transmit_data = transmit_call.
get_data();
93 if (
call.get_carrier_frequency().has_value()) {
94 transmit_data->set_carrier_frequency(
call.get_carrier_frequency().value());
98 if (
call.is_packed()) {
100 transmit_data->set_data_from_packed_sint32(
call.get_packed_data(),
call.get_packed_length(),
101 call.get_packed_count());
102 ESP_LOGD(TAG,
"Transmitting packed raw timings: count=%u, repeat=%u",
call.get_packed_count(),
103 call.get_repeat_count());
104 }
else if (
call.is_base64url()) {
106 if (!transmit_data->set_data_from_base64url(
call.get_base64url_data())) {
107 ESP_LOGE(TAG,
"Invalid base64url data");
111 constexpr int32_t max_timing_us = 500000;
112 for (int32_t timing : transmit_data->get_data()) {
113 int32_t abs_timing = timing < 0 ? -timing : timing;
114 if (abs_timing > max_timing_us) {
115 ESP_LOGE(TAG,
"Invalid timing value: %d µs (max %d)", timing, max_timing_us);
119 ESP_LOGD(TAG,
"Transmitting base64url raw timings: count=%zu, repeat=%u", transmit_data->get_data().size(),
120 call.get_repeat_count());
123 transmit_data->set_data(
call.get_raw_timings());
124 ESP_LOGD(TAG,
"Transmitting raw timings: count=%zu, repeat=%u",
call.get_raw_timings().size(),
125 call.get_repeat_count());
129 if (
call.get_repeat_count() > 0) {
130 transmit_call.set_send_times(
call.get_repeat_count());
134 transmit_call.perform();
151#if defined(USE_API) && defined(USE_IR_RF)
156 uint32_t device_id = 0;
ESPDEPRECATED("object_id mangles names and all object_id methods are planned for removal " "(see https://github.com/esphome/backlog/issues/76). " "Now is the time to stop using object_id. If still needed, use get_object_id_to() " "which will remain available longer. get_object_id() will be removed in 2026.7.0", "2025.12.0") std uint32_t get_object_id_hash()
const StringRef & get_name() const
uint32_t get_device_id() const
void send_infrared_rf_receive_event(uint32_t device_id, uint32_t key, const std::vector< int32_t > *timings)
InfraredCall - Builder pattern for transmitting infrared signals.
InfraredCall & set_raw_timings(const std::vector< int32_t > &timings)
Set the raw timings from a vector (positive = mark, negative = space)
InfraredCall & set_carrier_frequency(uint32_t frequency)
Set the carrier frequency in Hz.
InfraredCall & set_repeat_count(uint32_t count)
Set the number of times to repeat transmission (1 = transmit once, 2 = transmit twice,...
void perform()
Perform the transmission.
InfraredCall & set_raw_timings_packed(const uint8_t *data, uint16_t length, uint16_t count)
Set the raw timings from packed protobuf sint32 data (zigzag + varint encoded)
const std::string * base64url_ptr_
optional< uint32_t > carrier_frequency_
const uint8_t * packed_data_
InfraredCall & set_raw_timings_base64url(const std::string &base64url)
Set the raw timings from base64url-encoded little-endian int32 data.
const std::vector< int32_t > * raw_timings_
void dump_config() override
remote_base::RemoteReceiverBase * receiver_
bool on_receive(remote_base::RemoteReceiveData data) override
Called when IR data is received (from RemoteReceiverListener)
InfraredCall make_call()
Create a call object for transmitting.
virtual void control(const InfraredCall &call)
Perform the actual transmission (called by InfraredCall)
remote_base::RemoteTransmitterBase * transmitter_
friend class InfraredCall
bool has_transmitter() const
Check if this infrared has a transmitter configured.
bool has_receiver() const
Check if this infrared has a receiver configured.
uint32_t get_capability_flags() const
Get capability flags for this infrared instance.
bool get_supports_transmitter() const
bool get_supports_receiver() const
void set_supports_transmitter(bool supports)
void set_supports_receiver(bool supports)
const RawTimings & get_raw_data() const
void register_listener(RemoteReceiverListener *listener)
RemoteTransmitData * get_data()
APIServer * global_api_server