esphome-ratgdo/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp

31 lines
1.2 KiB
C++
Raw Normal View History

2023-06-07 15:37:51 +00:00
#include "ratgdo_binary_sensor.h"
#include "../ratgdo_state.h"
2023-06-07 16:41:02 +00:00
#include "esphome/core/log.h"
2023-06-07 15:37:51 +00:00
namespace esphome {
namespace ratgdo {
2023-06-07 16:41:02 +00:00
static const char* const TAG = "ratgdo.binary_sensor";
2023-06-07 16:40:49 +00:00
2023-06-07 16:41:02 +00:00
void RATGDOBinarySensor::dump_config()
{
LOG_BINARY_SENSOR("", "RATGDO BinarySensor", this);
ESP_LOGCONFIG(TAG, " Type: %s", this->type_ == SensorType::RATGDO_SENSOR_MOTION ? "Motion" : "Obstruction");
}
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);
}
void RATGDOBinarySensor::on_door_state(esphome::ratgdo::DoorState state) { }
void RATGDOBinarySensor::on_light_state(esphome::ratgdo::LightState state) { }
void RATGDOBinarySensor::on_lock_state(esphome::ratgdo::LockState state) { }
2023-06-07 15:37:51 +00:00
2023-06-07 16:41:02 +00:00
} // namespace ratgdo
} // namespace esphome