mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Update radon_eye_listener.cpp for more possible variants (#7567)
This commit is contained in:
parent
6139b933c5
commit
9211aad524
1 changed files with 10 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "radon_eye_listener.h"
|
#include "radon_eye_listener.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
|
|
||||||
|
@ -10,9 +12,14 @@ static const char *const TAG = "radon_eye_ble";
|
||||||
|
|
||||||
bool RadonEyeListener::parse_device(const esp32_ble_tracker::ESPBTDevice &device) {
|
bool RadonEyeListener::parse_device(const esp32_ble_tracker::ESPBTDevice &device) {
|
||||||
if (not device.get_name().empty()) {
|
if (not device.get_name().empty()) {
|
||||||
if (device.get_name().rfind("FR:R", 0) == 0) {
|
// Vector containing the prefixes to search for
|
||||||
// This is an RD200, I think
|
std::vector<std::string> prefixes = {"FR:R", "FR:I", "FR:H"};
|
||||||
ESP_LOGD(TAG, "Found Radon Eye RD200 device Name: %s (MAC: %s)", device.get_name().c_str(),
|
|
||||||
|
// Check if the device name starts with any of the prefixes
|
||||||
|
if (std::any_of(prefixes.begin(), prefixes.end(),
|
||||||
|
[&](const std::string &prefix) { return device.get_name().rfind(prefix, 0) == 0; })) {
|
||||||
|
// Device found
|
||||||
|
ESP_LOGD(TAG, "Found Radon Eye device Name: %s (MAC: %s)", device.get_name().c_str(),
|
||||||
device.address_str().c_str());
|
device.address_str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue