Avoid publishing of home presence data for HASS when WL or BL are set

This commit is contained in:
Florian committed 2019-06-21 20:22:11 +02:00
1 parent 1ef8fff99e
commit de93fd0da0
1 file changed
+10 -6
+10 -6
View File
@@ -64,6 +64,11 @@ vector<BLEdevice> devices;
mac_adress.replace(":","");
mac_adress.toUpperCase();
String mactopic = subjectBTtoMQTT + mac_adress;
char mac[mac_adress.length()+1];
mac_adress.toCharArray(mac,mac_adress.length()+1);
trc("device detected");
trc(mac);
if((!oneWhite() || isWhite(mac)) && !isBlack(mac)){ //if not black listed mac we go AND if we have no white mac or this mac is white we go out
if (advertisedDevice.haveName()) BLEdata.set("name", (char *)advertisedDevice.getName().c_str());
if (advertisedDevice.haveManufacturerData()) BLEdata.set("manufacturerdata", (char *)advertisedDevice.getManufacturerData().c_str());
if (advertisedDevice.haveRSSI()) BLEdata.set("rssi", (int) advertisedDevice.getRSSI());
@@ -72,8 +77,6 @@ vector<BLEdevice> devices;
if (advertisedDevice.haveRSSI()) haRoomPresence(BLEdata);// this device has an rssi in consequence we can use it for home assistant room presence component
#endif
if (advertisedDevice.haveServiceData()){
char mac[mac_adress.length()+1];
mac_adress.toCharArray(mac,mac_adress.length()+1);
trc(F("Get services data :"));
int serviceDataCount = advertisedDevice.getServiceDataCount();
trc(serviceDataCount);
@@ -96,7 +99,6 @@ vector<BLEdevice> devices;
BLEdata.set("servicedata", service_data);
BLEdata.set("servicedatauuid", (char *)advertisedDevice.getServiceDataUUID(j).toString().c_str());
#endif
if((!oneWhite() || isWhite(mac)) && !isBlack(mac)){ //if not black listed mac we go AND if we have no white mac or this mac is white we go out
pub((char *)mactopic.c_str(),BLEdata);
if (strstr(BLEdata["servicedatauuid"].as<char*>(),"fe95") != NULL){
trc("Processing BLE device data");
@@ -142,6 +144,8 @@ vector<BLEdevice> devices;
}
}
}
}else{
trc(F("Filtered mac device"));
}
}
};
@@ -280,6 +284,9 @@ vector<BLEdevice> devices;
trc(F("Creating BLE buffer"));
StaticJsonBuffer<JSON_MSG_BUFFER> jsonBuffer;
JsonObject& BLEdata = jsonBuffer.createObject();
strupp(d[0].extract);
if(isBlack(d[0].extract)) return false; //if black listed mac we go out
if(oneWhite() && !isWhite(d[0].extract)) return false; //if we have at least one white mac and this mac is not white we go out
#ifdef subjectHomePresence
String HomePresenceId;
for (int i = 0; i<12; i++){
@@ -290,9 +297,6 @@ vector<BLEdevice> devices;
trc(HomePresenceId);
BLEdata.set("id", (char *)HomePresenceId.c_str());
#endif
strupp(d[0].extract);
if(isBlack(d[0].extract)) return false; //if black listed mac we go out
if(oneWhite() && !isWhite(d[0].extract)) return false; //if we have at least one white mac and this mac is not white we go out
String topic = subjectBTtoMQTT + String(d[0].extract);
int rssi = (int)strtol(d[2].extract, NULL, 16) - 256;
BLEdata.set("rssi", (int)rssi);