add nodes to trigger read states

This commit is contained in:
technyon
2023-02-14 19:59:45 +01:00
parent 0bfeb96602
commit 1a6e74ef14
12 changed files with 140 additions and 23 deletions

View File

@@ -43,6 +43,13 @@ void NetworkOpener::initialize()
_network->subscribe(_mqttPath, topic);
}
_network->initTopic(_mqttPath, mqtt_topic_query_config, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_lockstate, "0");
_network->initTopic(_mqttPath, mqtt_topic_query_battery, "0");
_network->subscribe(_mqttPath, mqtt_topic_query_config);
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
_network->subscribe(_mqttPath, mqtt_topic_query_battery);
if(_preferences->getBool(preference_keypad_control_enabled))
{
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
@@ -50,11 +57,13 @@ void NetworkOpener::initialize()
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_name);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
_network->subscribe(_mqttPath, mqtt_topic_query_keypad);
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
}
_network->addReconnectedCallback([&]()
@@ -134,6 +143,26 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
{
_keypadCommandEnabled = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
{
_queryCommands = _queryCommands | QUERY_COMMAND_CONFIG;
publishString(mqtt_topic_query_config, "0");
}
else if(comparePrefixedPath(topic, mqtt_topic_query_lockstate) && strcmp(value, "1") == 0)
{
_queryCommands = _queryCommands | QUERY_COMMAND_LOCKSTATE;
publishString(mqtt_topic_query_lockstate, "0");
}
else if(comparePrefixedPath(topic, mqtt_topic_query_keypad) && strcmp(value, "1") == 0)
{
_queryCommands = _queryCommands | QUERY_COMMAND_KEYPAD;
publishString(mqtt_topic_query_keypad, "0");
}
else if(comparePrefixedPath(topic, mqtt_topic_query_battery) && strcmp(value, "1") == 0)
{
_queryCommands = _queryCommands | QUERY_COMMAND_BATTERY;
publishString(mqtt_topic_query_battery, "0");
}
for(auto configTopic : _configTopics)
{
@@ -611,4 +640,11 @@ bool NetworkOpener::reconnected()
bool r = _reconnected;
_reconnected = false;
return r;
}
}
uint8_t NetworkOpener::queryCommands()
{
uint8_t qc = _queryCommands;
_queryCommands = 0;
return qc;
}