2023-06-07 15:37:51 +00:00
|
|
|
#include "ratgdo_binary_sensor.h"
|
|
|
|
#include "esphome/core/log.h"
|
|
|
|
#include "../ratgdo_state.h"
|
|
|
|
|
|
|
|
namespace esphome {
|
|
|
|
namespace ratgdo {
|
|
|
|
|
2023-06-07 15:49:45 +00:00
|
|
|
static const char *const TAG = "ratgdo.binary_sensor";
|
2023-06-07 15:37:51 +00:00
|
|
|
|
2023-06-07 16:26:39 +00:00
|
|
|
void RATGDOBinarySensor::dump_config() {
|
2023-06-07 15:37:51 +00:00
|
|
|
LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this);
|
2023-06-07 16:31:35 +00:00
|
|
|
ESP_LOGCONFIG(" Type: %s", this->type_);
|
2023-06-07 16:31:02 +00:00
|
|
|
|
2023-06-07 15:37:51 +00:00
|
|
|
}
|
2023-06-07 16:37:34 +00:00
|
|
|
void RATGDOBinarySensor::on_motion_state(esphome::ratgdo::MotionState state) {
|
|
|
|
if (this->type_ == SensorType::RATGDO_SENSOR_MOTION)
|
|
|
|
this->publish_state(state == esphome::ratgdo::MotionState::MOTION_STATE_DETECTED);
|
|
|
|
}
|
|
|
|
void RATGDOBinarySensor::on_obstruction_state(esphome::ratgdo::ObstructionState state) {
|
|
|
|
if (this->type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION)
|
|
|
|
this->publish_state(state == esphome::ratgdo::ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED);
|
|
|
|
}
|
2023-06-07 15:37:51 +00:00
|
|
|
} // namespace ratgdo
|
|
|
|
} // namespace esphome
|
|
|
|
|