diff --git a/esphome/components/ble_presence/ble_presence_device.cpp b/esphome/components/ble_presence/ble_presence_device.cpp index 48ae7922da..66b92127c0 100644 --- a/esphome/components/ble_presence/ble_presence_device.cpp +++ b/esphome/components/ble_presence/ble_presence_device.cpp @@ -9,17 +9,17 @@ namespace esphome { namespace ble_presence { static const char *const TAG = "ble_presence"; -static const int min_rssi = -100; -static const int max_rssi = -30; +static const int MIN_RSSI = -100; +static const int MAX_RSSI = -30; void BLEPresenceDevice::dump_config() { LOG_BINARY_SENSOR("", "BLE Presence", this); } void BLEPresenceDevice::set_minimum_rssi_input(number::Number *min_rssi_number) { min_rssi_number->add_on_state_callback([this](float state) { int rssi = int(state); - if (rssi < min_rssi || rssi > max_rssi) { - ESP_LOGW(TAG, "Valid RSSI range is %ddB to %ddB", min_rssi, max_rssi); - rssi = std::min(std::max(rssi, min_rssi), max_rssi); + if (rssi < MIN_RSSI || rssi > MAX_RSSI) { + ESP_LOGW(TAG, "Valid RSSI range is %ddB to %ddB", MIN_RSSI, MAX_RSSI); + rssi = std::min(std::max(rssi, MIN_RSSI), MAX_RSSI); } ESP_LOGI(TAG, "Setting minimum rssi to %ddB", rssi); this->set_minimum_rssi_(int(state)); diff --git a/tests/components/ble_presence/common.yaml b/tests/components/ble_presence/common.yaml index 82040cac11..a211f5640b 100644 --- a/tests/components/ble_presence/common.yaml +++ b/tests/components/ble_presence/common.yaml @@ -38,5 +38,3 @@ binary_sensor: service_uuid: 11223344-5566-7788-99aa-bbccddeeff00 name: BLE Test Service Min RSSI min_rssi_number_id: min_rssi - -