move publish presence detection to Network class
This commit is contained in:
@@ -40,6 +40,8 @@ void NetworkLock::initialize()
|
||||
_preferences->putString(preference_mqtt_lock_path, _mqttPath);
|
||||
}
|
||||
|
||||
_network->setMqttPresencePath(_mqttPath);
|
||||
|
||||
_network->subscribe(_mqttPath, mqtt_topic_lock_action);
|
||||
for(const auto& topic : _configTopics)
|
||||
{
|
||||
@@ -47,20 +49,6 @@ void NetworkLock::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkLock::update()
|
||||
{
|
||||
if(_presenceCsv != nullptr && strlen(_presenceCsv) > 0)
|
||||
{
|
||||
bool success = publishString(mqtt_topic_presence, _presenceCsv);
|
||||
if(!success)
|
||||
{
|
||||
Serial.println(F("Failed to publish presence CSV data."));
|
||||
Serial.println(_presenceCsv);
|
||||
}
|
||||
_presenceCsv = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkLock::onMqttDataReceived(char *&topic, byte *&payload, unsigned int &length)
|
||||
{
|
||||
char value[50] = {0};
|
||||
@@ -181,11 +169,6 @@ void NetworkLock::publishAdvancedConfig(const NukiLock::AdvancedConfig &config)
|
||||
publishBool(mqtt_topic_config_auto_lock, config.autoLockEnabled == 1);
|
||||
}
|
||||
|
||||
void NetworkLock::publishPresenceDetection(char *csv)
|
||||
{
|
||||
_presenceCsv = csv;
|
||||
}
|
||||
|
||||
void NetworkLock::setLockActionReceivedCallback(bool (*lockActionReceivedCallback)(const char *))
|
||||
{
|
||||
_lockActionReceivedCallback = lockActionReceivedCallback;
|
||||
|
||||
Reference in New Issue
Block a user