ESPHome
2024.4.1
esphome
esphome
components
tuya
binary_sensor
tuya_binary_sensor.cpp
Go to the documentation of this file.
1
#include "
esphome/core/log.h
"
2
#include "
tuya_binary_sensor.h
"
3
4
namespace
esphome
{
5
namespace
tuya {
6
7
static
const
char
*
const
TAG
=
"tuya.binary_sensor"
;
8
9
void
TuyaBinarySensor::setup
() {
10
this->
parent_
->
register_listener
(this->
sensor_id_
, [
this
](
const
TuyaDatapoint
&datapoint) {
11
ESP_LOGV(TAG,
"MCU reported binary sensor %u is: %s"
, datapoint.
id
, ONOFF(datapoint.
value_bool
));
12
this->
publish_state
(datapoint.
value_bool
);
13
});
14
}
15
16
void
TuyaBinarySensor::dump_config
() {
17
ESP_LOGCONFIG(TAG,
"Tuya Binary Sensor:"
);
18
ESP_LOGCONFIG(TAG,
" Binary Sensor has datapoint ID %u"
, this->
sensor_id_
);
19
}
20
21
}
// namespace tuya
22
}
// namespace esphome
esphome::tuya::TuyaDatapoint::id
uint8_t id
Definition:
tuya.h:29
esphome::tuya::TuyaDatapoint::value_bool
bool value_bool
Definition:
tuya.h:33
esphome::tuya::TuyaBinarySensor::parent_
Tuya * parent_
Definition:
tuya_binary_sensor.h:19
esphome::tuya::Tuya::register_listener
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
Definition:
tuya.cpp:667
esphome::tuya::TuyaDatapoint
Definition:
tuya.h:28
esphome::spi::TAG
const char *const TAG
Definition:
spi.cpp:8
esphome::tuya::TuyaBinarySensor::setup
void setup() override
Definition:
tuya_binary_sensor.cpp:9
esphome::tuya::TuyaBinarySensor::dump_config
void dump_config() override
Definition:
tuya_binary_sensor.cpp:16
esphome::binary_sensor::BinarySensor::publish_state
void publish_state(bool state)
Publish a new state to the front-end.
Definition:
binary_sensor.cpp:14
tuya_binary_sensor.h
esphome::tuya::TuyaBinarySensor::sensor_id_
uint8_t sensor_id_
Definition:
tuya_binary_sensor.h:20
esphome
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition:
a01nyub.cpp:7
log.h
Generated by
1.8.13