move publish presence detection to Network class

This commit is contained in:
technyon
2022-07-02 12:46:18 +02:00
parent beb87a959f
commit 4f442d7b1d
9 changed files with 35 additions and 43 deletions

View File

@@ -129,6 +129,17 @@ int Network::update()
}
}
if(_presenceCsv != nullptr && strlen(_presenceCsv) > 0)
{
bool success = publishString(_mqttPresencePrefix, mqtt_topic_presence, _presenceCsv);
if(!success)
{
Serial.println(F("Failed to publish presence CSV data."));
Serial.println(_presenceCsv);
}
_presenceCsv = nullptr;
}
_device->mqttClient()->loop();
return 0;
}
@@ -233,6 +244,12 @@ void Network::reconfigureDevice()
_device->reconfigure();
}
void Network::setMqttPresencePath(char *path)
{
memset(_mqttPresencePrefix, 0, sizeof(_mqttPresencePrefix));
strcpy(_mqttPresencePrefix, path);
}
bool Network::isMqttConnected()
{
return _mqttConnected;
@@ -372,4 +389,9 @@ void Network::removeHASSConfig(char* uidString)
_device->mqttClient()->publish(path.c_str(), NULL, 0U, true);
}
}
}
void Network::publishPresenceDetection(char *csv)
{
_presenceCsv = csv;
}