From 32f76632c731ec91626f032cab1468a928c7589c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 9 Jun 2023 16:48:48 -0500 Subject: [PATCH] loop --- .../ratgdo/binary_sensor/ratgdo_binary_sensor.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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