Retain Input GPIO
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
#define NUKI_HUB_VERSION "9.05"
|
#define NUKI_HUB_VERSION "9.05"
|
||||||
#define NUKI_HUB_VERSION_INT (uint32_t)905
|
#define NUKI_HUB_VERSION_INT (uint32_t)905
|
||||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||||
#define NUKI_HUB_DATE "2024-12-19"
|
#define NUKI_HUB_DATE "2024-12-20"
|
||||||
|
|
||||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ void NukiNetwork::initialize()
|
|||||||
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pinEntry.pin)).c_str(), mqtt_topic_gpio_role});
|
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pinEntry.pin)).c_str(), mqtt_topic_gpio_role});
|
||||||
publishString(_lockPath.c_str(), gpioPath, "input", false);
|
publishString(_lockPath.c_str(), gpioPath, "input", false);
|
||||||
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pinEntry.pin)).c_str(), mqtt_topic_gpio_state});
|
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pinEntry.pin)).c_str(), mqtt_topic_gpio_state});
|
||||||
publishString(_lockPath.c_str(), gpioPath, std::to_string(digitalRead(pinEntry.pin)).c_str(), false);
|
publishString(_lockPath.c_str(), gpioPath, std::to_string(digitalRead(pinEntry.pin)).c_str(), _retainGpio);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PinRole::GeneralOutput:
|
case PinRole::GeneralOutput:
|
||||||
@@ -353,6 +353,7 @@ void NukiNetwork::readSettings()
|
|||||||
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect, false);
|
_restartOnDisconnect = _preferences->getBool(preference_restart_on_disconnect, false);
|
||||||
_checkUpdates = _preferences->getBool(preference_check_updates, false);
|
_checkUpdates = _preferences->getBool(preference_check_updates, false);
|
||||||
_rssiPublishInterval = _preferences->getInt(preference_rssi_publish_interval, 0) * 1000;
|
_rssiPublishInterval = _preferences->getInt(preference_rssi_publish_interval, 0) * 1000;
|
||||||
|
_retainGpio = _preferences->getBool(preference_retain_gpio, false);
|
||||||
|
|
||||||
if(_rssiPublishInterval == 0)
|
if(_rssiPublishInterval == 0)
|
||||||
{
|
{
|
||||||
@@ -573,7 +574,7 @@ bool NukiNetwork::update()
|
|||||||
uint8_t pinState = digitalRead(pin) == HIGH ? 1 : 0;
|
uint8_t pinState = digitalRead(pin) == HIGH ? 1 : 0;
|
||||||
char gpioPath[250];
|
char gpioPath[250];
|
||||||
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pin)).c_str(), mqtt_topic_gpio_state});
|
buildMqttPath(gpioPath, {mqtt_topic_gpio_prefix, (mqtt_topic_gpio_pin + std::to_string(pin)).c_str(), mqtt_topic_gpio_state});
|
||||||
publishInt(_lockPath.c_str(), gpioPath, pinState, false);
|
publishInt(_lockPath.c_str(), gpioPath, pinState, _retainGpio);
|
||||||
|
|
||||||
Log->print(F("GPIO "));
|
Log->print(F("GPIO "));
|
||||||
Log->print(pin);
|
Log->print(pin);
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ private:
|
|||||||
bool _firstConnect = true;
|
bool _firstConnect = true;
|
||||||
bool _publishDebugInfo = false;
|
bool _publishDebugInfo = false;
|
||||||
bool _logIp = true;
|
bool _logIp = true;
|
||||||
|
bool _retainGpio = false;
|
||||||
std::vector<String> _subscribedTopics;
|
std::vector<String> _subscribedTopics;
|
||||||
std::map<String, String> _initTopics;
|
std::map<String, String> _initTopics;
|
||||||
int64_t _lastConnectedTs = 0;
|
int64_t _lastConnectedTs = 0;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@
|
|||||||
#define preference_official_hybrid_actions (char*)"hybridAct"
|
#define preference_official_hybrid_actions (char*)"hybridAct"
|
||||||
#define preference_official_hybrid_retry (char*)"hybridRtry"
|
#define preference_official_hybrid_retry (char*)"hybridRtry"
|
||||||
#define preference_keypad_check_code_enabled (char*)"kpChkEna"
|
#define preference_keypad_check_code_enabled (char*)"kpChkEna"
|
||||||
|
#define preference_retain_gpio (char*)"retGpio"
|
||||||
|
|
||||||
//NOT USER CHANGABLE
|
//NOT USER CHANGABLE
|
||||||
#define preference_updater_version (char*)"updVer"
|
#define preference_updater_version (char*)"updVer"
|
||||||
@@ -217,6 +218,8 @@ inline void initPreferences(Preferences* preferences)
|
|||||||
preferences->putBool(preference_debug_command, false);
|
preferences->putBool(preference_debug_command, false);
|
||||||
preferences->putBool(preference_connect_mode, true);
|
preferences->putBool(preference_connect_mode, true);
|
||||||
|
|
||||||
|
preferences->putBool(preference_retain_gpio, false);
|
||||||
|
|
||||||
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
#ifndef CONFIG_IDF_TARGET_ESP32H2
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
WiFi.disconnect(true, true);
|
WiFi.disconnect(true, true);
|
||||||
@@ -375,7 +378,7 @@ private:
|
|||||||
preference_network_custom_rst, preference_network_custom_cs, preference_network_custom_sck, preference_network_custom_miso, preference_network_custom_mosi,
|
preference_network_custom_rst, preference_network_custom_cs, preference_network_custom_sck, preference_network_custom_miso, preference_network_custom_mosi,
|
||||||
preference_network_custom_pwr, preference_network_custom_mdio, preference_ntw_reconfigure, preference_lock_max_auth_entry_count, preference_opener_max_auth_entry_count,
|
preference_network_custom_pwr, preference_network_custom_mdio, preference_ntw_reconfigure, preference_lock_max_auth_entry_count, preference_opener_max_auth_entry_count,
|
||||||
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_auth_max_entries, preference_wifi_ssid, preference_wifi_pass,
|
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_auth_max_entries, preference_wifi_ssid, preference_wifi_pass,
|
||||||
preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_mqtt_hass_enabled, preference_hass_device_discovery,
|
preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_mqtt_hass_enabled, preference_hass_device_discovery, preference_retain_gpio,
|
||||||
preference_debug_connect, preference_debug_communication, preference_debug_readable_data, preference_debug_hex_data, preference_debug_command, preference_connect_mode
|
preference_debug_connect, preference_debug_communication, preference_debug_readable_data, preference_debug_hex_data, preference_debug_command, preference_connect_mode
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -390,7 +393,7 @@ private:
|
|||||||
preference_timecontrol_topic_per_entry, preference_keypad_topic_per_entry, preference_enable_bootloop_reset, preference_webserver_enabled,
|
preference_timecontrol_topic_per_entry, preference_keypad_topic_per_entry, preference_enable_bootloop_reset, preference_webserver_enabled,
|
||||||
preference_restart_on_disconnect, preference_keypad_control_enabled, preference_keypad_info_enabled, preference_keypad_publish_code, preference_show_secrets,
|
preference_restart_on_disconnect, preference_keypad_control_enabled, preference_keypad_info_enabled, preference_keypad_publish_code, preference_show_secrets,
|
||||||
preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_register_as_app, preference_register_opener_as_app, preference_ip_dhcp_enabled,
|
preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_register_as_app, preference_register_opener_as_app, preference_ip_dhcp_enabled,
|
||||||
preference_publish_authdata, preference_publish_debug_info, preference_official_hybrid_enabled, preference_mqtt_hass_enabled,
|
preference_publish_authdata, preference_publish_debug_info, preference_official_hybrid_enabled, preference_mqtt_hass_enabled, preference_retain_gpio,
|
||||||
preference_official_hybrid_actions, preference_official_hybrid_retry, preference_conf_info_enabled, preference_disable_non_json, preference_update_from_mqtt,
|
preference_official_hybrid_actions, preference_official_hybrid_retry, preference_conf_info_enabled, preference_disable_non_json, preference_update_from_mqtt,
|
||||||
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_webserial_enabled, preference_hass_device_discovery,
|
preference_auth_control_enabled, preference_auth_topic_per_entry, preference_auth_info_enabled, preference_webserial_enabled, preference_hass_device_discovery,
|
||||||
preference_ntw_reconfigure, preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_find_best_rssi,
|
preference_ntw_reconfigure, preference_keypad_check_code_enabled, preference_disable_network_not_connected, preference_find_best_rssi,
|
||||||
|
|||||||
@@ -3317,6 +3317,16 @@ void WebCfgServer::processGpioArgs(PsychicRequest *request)
|
|||||||
for(int index = 0; index < params; index++)
|
for(int index = 0; index < params; index++)
|
||||||
{
|
{
|
||||||
const PsychicWebParameter* p = request->getParam(index);
|
const PsychicWebParameter* p = request->getParam(index);
|
||||||
|
|
||||||
|
if(p->name() == "RETGPIO")
|
||||||
|
{
|
||||||
|
if(_preferences->getBool(preference_retain_gpio, false) != (p->value() == "1"))
|
||||||
|
{
|
||||||
|
_preferences->putBool(preference_retain_gpio, (p->value() == "1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
PinRole role = (PinRole)p->value().toInt();
|
PinRole role = (PinRole)p->value().toInt();
|
||||||
if(role != PinRole::Disabled)
|
if(role != PinRole::Disabled)
|
||||||
{
|
{
|
||||||
@@ -3326,6 +3336,7 @@ void WebCfgServer::processGpioArgs(PsychicRequest *request)
|
|||||||
pinConfiguration.push_back(entry);
|
pinConfiguration.push_back(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_gpio->savePinConfiguration(pinConfiguration);
|
_gpio->savePinConfiguration(pinConfiguration);
|
||||||
}
|
}
|
||||||
@@ -4037,6 +4048,8 @@ esp_err_t WebCfgServer::buildGpioConfigHtml(PsychicRequest *request)
|
|||||||
response.print("<form method=\"post\" action=\"savegpiocfg\">");
|
response.print("<form method=\"post\" action=\"savegpiocfg\">");
|
||||||
response.print("<h3>GPIO Configuration</h3>");
|
response.print("<h3>GPIO Configuration</h3>");
|
||||||
response.print("<table>");
|
response.print("<table>");
|
||||||
|
printCheckBox(&response, "RETGPIO", "Retain Input GPIO MQTT state", _preferences->getBool(preference_retain_gpio, false), "");
|
||||||
|
|
||||||
std::vector<std::pair<String, String>> options;
|
std::vector<std::pair<String, String>> options;
|
||||||
String gpiopreselects = "var gpio = []; ";
|
String gpiopreselects = "var gpio = []; ";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user