diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index 35a9b46..30a01bd 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -65,7 +65,7 @@ namespace ratgdo { observable closing_delay { 0 }; observable target_distance_measurement { -1 }; - std::vector distance_measurement { std::vector(10, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states + std::vector distance_measurement { std::vector(30, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states observable last_distance_measurement { 0 }; observable openings { 0 }; // number of times the door has been opened diff --git a/components/ratgdo/sensor/ratgdo_sensor.cpp b/components/ratgdo/sensor/ratgdo_sensor.cpp index e90017f..77cafab 100644 --- a/components/ratgdo/sensor/ratgdo_sensor.cpp +++ b/components/ratgdo/sensor/ratgdo_sensor.cpp @@ -88,15 +88,13 @@ namespace ratgdo { objCount = pDistanceData->NumberOfObjectsFound; maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter; - /* if(maxDistance < 0) maxDistance = -1; - * if the sensor is pointed at glass, there are many error readings which will fill the + /* + * if the sensor is pointed at glass, there are many error -1 readings which will fill the * vector with out of range data. The sensor should be sensitive enough to detect the floor - * in most situations, unless its mounted really far away. - * If this doesn't work, then the vector size will have to increase substantially + * in most situations, but daylight and/or really high ceilings can cause long distance + * measurements to be out of range. */ - if (maxDistance > 0) { - this->parent_->set_distance_measurement(maxDistance); - } + this->parent_->set_distance_measurement(maxDistance); // ESP_LOGD(TAG,"# obj found %d; distance %d",objCount, maxDistance);