diff --git a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp index 70f2f11..cb235f2 100644 --- a/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp +++ b/components/ratgdo/binary_sensor/ratgdo_binary_sensor.cpp @@ -26,21 +26,24 @@ namespace ratgdo { } void RATGDOBinarySensor::on_motion_state(MotionState state) { + if (this->binary_sensor_type_ != SensorType::RATGDO_SENSOR_MOTION) + return; ESP_LOGD(TAG, "name: %s this->type_:%d on_motion_state: %d", this->get_name(), this->binary_sensor_type_, state); - if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_MOTION) - this->publish_state(state == MotionState::MOTION_STATE_DETECTED); + this->publish_state(state == MotionState::MOTION_STATE_DETECTED); } void RATGDOBinarySensor::on_obstruction_state(ObstructionState state) { + if (this->binary_sensor_type_ != SensorType::RATGDO_SENSOR_OBSTRUCTION) + return; ESP_LOGD(TAG, "name: %s this->type_:%d on_obstruction_state: %d", this->get_name(), this->binary_sensor_type_, state); - if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_OBSTRUCTION) - this->publish_state(state == ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED); + this->publish_state(state == ObstructionState::OBSTRUCTION_STATE_OBSTRUCTED); } void RATGDOBinarySensor::on_motor_state(MotorState state) { + if (this->binary_sensor_type_ != SensorType::RATGDO_SENSOR_MOTOR) + return; ESP_LOGD(TAG, "name: %s this->type_:%d on_motor_state: %d", this->get_name(), this->binary_sensor_type_, state); - if (this->binary_sensor_type_ == SensorType::RATGDO_SENSOR_MOTOR) - this->publish_state(state == MotorState::MOTOR_STATE_ON); + this->publish_state(state == MotorState::MOTOR_STATE_ON); } } // namespace ratgdo