make single lock configurable

This commit is contained in:
technyon
2022-07-14 20:02:38 +02:00
parent af24eeb0e9
commit 13dae4eb0d
4 changed files with 11 additions and 1 deletions

View File

@@ -22,5 +22,6 @@
#define mqtt_topic_config_led_brightness "/configuration/ledBrightness"
#define mqtt_topic_config_auto_unlock "/configuration/autoUnlock"
#define mqtt_topic_config_auto_lock "/configuration/autoLock"
#define mqtt_topic_config_single_lock "/configuration/singleLock"
#define mqtt_topic_presence "/presence/devices"

View File

@@ -15,6 +15,7 @@ NetworkLock::NetworkLock(Network* network, Preferences* preferences)
_configTopics.push_back(mqtt_topic_config_led_brightness);
_configTopics.push_back(mqtt_topic_config_auto_unlock);
_configTopics.push_back(mqtt_topic_config_auto_lock);
_configTopics.push_back(mqtt_topic_config_single_lock);
_network->registerMqttReceiver(this);
}
@@ -156,6 +157,7 @@ void NetworkLock::publishConfig(const NukiLock::Config &config)
publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1);
publishBool(mqtt_topic_config_led_enabled, config.ledEnabled == 1);
publishInt(mqtt_topic_config_led_brightness, config.ledBrightness);
publishBool(mqtt_topic_config_single_lock, config.singleLock == 1);
}
void NetworkLock::publishAdvancedConfig(const NukiLock::AdvancedConfig &config)

View File

@@ -281,6 +281,13 @@ void NukiWrapper::onConfigUpdateReceived(const char *topic, const char *value)
_nukiLock.setLedBrightness(newValue);
_nextConfigUpdateTs = millis() + 300;
}
if(strcmp(topic, mqtt_topic_config_single_lock) == 0)
{
bool newValue = atoi(value) > 0;
if(!_nukiConfigValid || _nukiConfig.singleLock == newValue) return;
_nukiLock.enableSingleLock(newValue);
_nextConfigUpdateTs = millis() + 300;
}
else if(strcmp(topic, mqtt_topic_config_auto_unlock) == 0)
{
bool newValue = !(atoi(value) > 0);

View File

@@ -37,7 +37,7 @@ Just enable pairing mode on the NUKI lock (press button for a few seconds) and p
## Support
If you haven't ordered your NUKI product yet, you can support me by using my referrer code when placing your order:<br>
REFN8VHZXUBV4<br>
REFSHC6Z6QZ4P<br>
This will also give you a 30€ discount for your order.
## MQTT Interface