[DISC] always auto-discover Presence/Tracker timeout (#1959)
auto-discover Presence/Tracker timeout even when HASS presence is not active Also inject an additional placeholder rssi key and value into the BM2 voltage connection message to avoid the message being registered as a device tracker AWAY https://community.openmqttgateway.com/t/bm2-home-and-away/3315
This commit is contained in:
1 parent
6e906702ed
commit
d538316e03
3 files changed
+3
-7
No files matched your search
@@ -301,6 +301,8 @@ void BM2_connect::notifyCB(NimBLERemoteCharacteristic* pChar, uint8_t* pData, si
|
|||||||
float volt = ((output[2] | (output[1] << 8)) >> 4) / 100.0f;
|
float volt = ((output[2] | (output[1] << 8)) >> 4) / 100.0f;
|
||||||
BLEdata["volt"] = volt;
|
BLEdata["volt"] = volt;
|
||||||
Log.trace(F("volt: %F" CR), volt);
|
Log.trace(F("volt: %F" CR), volt);
|
||||||
|
// to avoid the BM2 device tracker going offline because of the voltage MQTT message without an RSSI value
|
||||||
|
BLEdata["rssi"] = -60;
|
||||||
buildTopicFromId(BLEdata, subjectBTtoMQTT);
|
buildTopicFromId(BLEdata, subjectBTtoMQTT);
|
||||||
handleJsonEnqueue(BLEdata, QueueSemaphoreTimeOutTask);
|
handleJsonEnqueue(BLEdata, QueueSemaphoreTimeOutTask);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -156,10 +156,6 @@ void BTConfig_fromJson(JsonObject& BTdata, bool startup = false) {
|
|||||||
if (startup == false) {
|
if (startup == false) {
|
||||||
if (BTdata.containsKey("hasspresence") && BTdata["hasspresence"] == false && BTConfig.presenceEnable == true) {
|
if (BTdata.containsKey("hasspresence") && BTdata["hasspresence"] == false && BTConfig.presenceEnable == true) {
|
||||||
BTdata["adaptivescan"] = true;
|
BTdata["adaptivescan"] = true;
|
||||||
# ifdef ZmqttDiscovery
|
|
||||||
// Remove discovered entities
|
|
||||||
eraseTopic("number", (char*)getUniqueId("presenceawaytimer", "").c_str());
|
|
||||||
# endif
|
|
||||||
} else if (BTdata.containsKey("hasspresence") && BTdata["hasspresence"] == true && BTConfig.presenceEnable == false) {
|
} else if (BTdata.containsKey("hasspresence") && BTdata["hasspresence"] == true && BTConfig.presenceEnable == false) {
|
||||||
BTdata["adaptivescan"] = false;
|
BTdata["adaptivescan"] = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -423,9 +423,8 @@ void eraseTopic(const char* sensor_type, const char* unique_id) {
|
|||||||
|
|
||||||
# ifdef ZgatewayBT
|
# ifdef ZgatewayBT
|
||||||
void btPresenceParametersDiscovery() {
|
void btPresenceParametersDiscovery() {
|
||||||
if (BTConfig.presenceEnable) {
|
|
||||||
createDiscovery("number", //set Type
|
createDiscovery("number", //set Type
|
||||||
subjectBTtoMQTT, "BT: Presence detection timer", (char*)getUniqueId("presenceawaytimer", "").c_str(), //set state_topic,name,uniqueId
|
subjectBTtoMQTT, "BT: Presence/Tracker timeout", (char*)getUniqueId("presenceawaytimer", "").c_str(), //set state_topic,name,uniqueId
|
||||||
will_Topic, "", "{{ value_json.presenceawaytimer/60000 }}", //set availability_topic,device_class,value_template,
|
will_Topic, "", "{{ value_json.presenceawaytimer/60000 }}", //set availability_topic,device_class,value_template,
|
||||||
"{\"presenceawaytimer\":{{value*60000}},\"save\":true}", "", "min", //set,payload_on,payload_off,unit_of_meas,
|
"{\"presenceawaytimer\":{{value*60000}},\"save\":true}", "", "min", //set,payload_on,payload_off,unit_of_meas,
|
||||||
0, //set off_delay
|
0, //set off_delay
|
||||||
@@ -433,7 +432,6 @@ void btPresenceParametersDiscovery() {
|
|||||||
"", "", "", "", false, // device name, device manufacturer, device model, device ID, retain,
|
"", "", "", "", false, // device name, device manufacturer, device model, device ID, retain,
|
||||||
stateClassNone //State Class
|
stateClassNone //State Class
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void btScanParametersDiscovery() {
|
void btScanParametersDiscovery() {
|
||||||
|
|||||||
Reference in new issue
Block a user