// sets the corresponding config variable for 'param' to new value
// does not trigger saving to flash
// does not distinguish between config sets as they are only split on flash and
// in web interface called from commands:
//   serial command: set [param] [value]
//   MQTT cmd topic, payload "set [param] [value]"
//     -> must be committed by command 'save' after all desired values are set
// called from web interface setConf functions, which also saves the changed
// conf set to flash immediately

void setConfig(char *param, char *value)
{
  //snprintf(logBuf, LOG_BUFFER_SIZE, "setConfig: '%s' set to '%s'", param, value);
  snprintf_P(logBuf, LOG_BUFFER_SIZE, PGMStr_setConf, param, value);
  sendLog(logBuf, LOGLEVEL_DEBUG);

  //char param_l[15];
  strlwr(param);


  // confDevWiFi
  if (strcmp(param, "devname") == 0)
  {
    if (strcmp(value, confDevWiFi.deviceName) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confDevWiFi.deviceName, "", sizeof(confDevWiFi.deviceName));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
      else
      {
        if (strlen(value) >= 4)
        {
          strlcpy(confDevWiFi.deviceName, value, sizeof(confDevWiFi.deviceName));
          configChangedRestartRequired = true;
          confDevWiFi_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "hostname") == 0)
  {
    if (strcmp(value, confDevWiFi.hostName) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confDevWiFi.hostName, "", sizeof(confDevWiFi.hostName));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
      else
      {
        if (strlen(value) >= 4)
        {
          strlcpy(confDevWiFi.hostName, value, sizeof(confDevWiFi.hostName));
          configChangedRestartRequired = true;
          confDevWiFi_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "ssid1") == 0)
  {
    if (strcmp(value, confDevWiFi.WiFiSSID1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confDevWiFi.WiFiSSID1, "", sizeof(confDevWiFi.WiFiSSID1));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
      else
      {
        strlcpy(confDevWiFi.WiFiSSID1, value, sizeof(confDevWiFi.WiFiSSID1));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "wpw1") == 0)
  {
    if (strcmp(value, confSecrets.WiFiPW1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.WiFiPW1, "", sizeof(confSecrets.WiFiPW1));
        configChangedRestartRequired = true;
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.WiFiPW1, value, sizeof(confSecrets.WiFiPW1));
          configChangedRestartRequired = true;
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "ssid2") == 0)
  {
    if (strcmp(value, confDevWiFi.WiFiSSID2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confDevWiFi.WiFiSSID2, "", sizeof(confDevWiFi.WiFiSSID2));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
      else
      {
        strlcpy(confDevWiFi.WiFiSSID2, value, sizeof(confDevWiFi.WiFiSSID2));
        configChangedRestartRequired = true;
        confDevWiFi_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "wpw2") == 0)
  {
    if (strcmp(value, confSecrets.WiFiPW2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.WiFiPW2, "", sizeof(confSecrets.WiFiPW2));
        configChangedRestartRequired = true;
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.WiFiPW2, value, sizeof(confSecrets.WiFiPW2));
          configChangedRestartRequired = true;
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "wpwap") == 0)
  {
    if (strcmp(value, confSecrets.WiFiAPModePassword) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.WiFiAPModePassword, "", sizeof(confSecrets.WiFiAPModePassword));
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.WiFiAPModePassword, value, sizeof(confSecrets.WiFiAPModePassword));
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "waptout") == 0)
  {
    int tmpval = atoi(value);
    if (tmpval != confDevWiFi.WiFiAPModeTimeout)
    {
      if (tmpval >= 0 && tmpval <= 120)
      {
        confDevWiFi.WiFiAPModeTimeout = tmpval;
        confDevWiFi_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }


  else if (strcmp(param, "wconncheck") == 0)
  {
    int tmpval = atoi(value);
    if (tmpval != confDevWiFi.WiFiConnCheckInterval)
    {
      if (tmpval == 0)
      {
        confDevWiFi.WiFiConnCheckInterval = 0;
        confDevWiFi_wasChanged = true;
      }
      else
      {
        if (tmpval >= 10 && tmpval <= 3600)
        {
          confDevWiFi.WiFiConnCheckInterval = tmpval;
          confDevWiFi_wasChanged = true;
        }
        else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
      }
    }
  }


  else if (strcmp(param, "wretry") == 0)
  {
    int tmpval = atoi(value);
    if (tmpval != confDevWiFi.WiFiRetryInterval)
    {
      if (tmpval >= 0 && tmpval <= 120)
      {
        confDevWiFi.WiFiRetryInterval = tmpval;
        confDevWiFi_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }


  else if (strcmp(param, "wreboot") == 0)
  {
    int tmpval = atoi(value);
    if (tmpval != confDevWiFi.WiFiRebootOnNoConnect)
    {
      if (tmpval >= 0 && tmpval <= 2880)
      {
        confDevWiFi.WiFiRebootOnNoConnect = tmpval;
        confDevWiFi_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }


  else if (strcmp(param, "ardota") == 0)
  {
    bool tmpval = false;
    if (atoi(value) == 1) tmpval = true;

    if(tmpval != confDevWiFi.enableArduinoOTA) {
      confDevWiFi.enableArduinoOTA = tmpval;
      configChangedRestartRequired = true;
      confDevWiFi_wasChanged = true;
    }
  }

  // confWeb
  else if (strcmp(param, "apitoken") == 0)
  {
    if (strcmp(value, confSecrets.http_token) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_token, "", sizeof(confSecrets.http_token));
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.http_token, value, sizeof(confSecrets.http_token));
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "httpua") == 0)
  {
    if (strcmp(value, confSecrets.http_user) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_user, "", sizeof(confSecrets.http_user));
        confSecrets_wasChanged = true;
      }
      else
      {
        strlcpy(confSecrets.http_user, value, sizeof(confSecrets.http_user));
        confSecrets_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "httppa") == 0)
  {
    if (strcmp(value, confSecrets.http_pass) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_pass, "", sizeof(confSecrets.http_pass));
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.http_pass, value, sizeof(confSecrets.http_pass));
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "httpauth") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confWeb.http_user_auth != tmpval)
    {
      confWeb.http_user_auth = tmpval;
      confWeb_wasChanged = true;
    }
  }


  else if (strcmp(param, "httpu1") == 0)
  {
    if (strcmp(value, confSecrets.http_user1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_user1, "", sizeof(confSecrets.http_user1));
        confSecrets_wasChanged = true;
      }
      else
      {
        strlcpy(confSecrets.http_user1, value, sizeof(confSecrets.http_user1));
        confSecrets_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "httpp1") == 0)
  {
    if (strcmp(value, confSecrets.http_pass1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_pass1, "", sizeof(confSecrets.http_pass1));
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.http_pass1, value, sizeof(confSecrets.http_pass1));
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "httpu2") == 0)
  {
    if (strcmp(value, confSecrets.http_user2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_user2, "", sizeof(confSecrets.http_user2));
        confSecrets_wasChanged = true;
      }
      else
      {
        strlcpy(confSecrets.http_user2, value, sizeof(confSecrets.http_user2));
        confSecrets_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "httpp2") == 0)
  {
    if (strcmp(value, confSecrets.http_pass2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.http_pass2, "", sizeof(confSecrets.http_pass2));
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.http_pass2, value, sizeof(confSecrets.http_pass2));
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "wconsole") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confWeb.wConsole != tmpval)
    {
      confWeb.wConsole = tmpval;
      configChangedRestartRequired = true;
      confWeb_wasChanged = true;
    }
  }


  else if (strcmp(param, "wsconsole") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confWeb.wsConsole != tmpval)
    {
      confWeb.wsConsole = tmpval;
      configChangedRestartRequired = true;
      confWeb_wasChanged = true;
    }
  }


#ifdef ENABLE_FEATURE_HTTP_UPDATER
  else if (strcmp(param, "enableota") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1) tmpval = true;
    else tmpval = false;
    if (confWeb.enableOTA != tmpval) {
      confWeb.enableOTA = tmpval;
      confWeb_wasChanged = true;
    }
  }
#endif


#ifdef ENABLE_FEATURE_FILESYSTEM_BROWSER
  else if (strcmp(param, "fsbrowser") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1) tmpval = true;
    else tmpval = false;
    if (confWeb.FSbrowser != tmpval) {
      confWeb.FSbrowser = tmpval;
      confWeb_wasChanged = true;
    }
  }
#endif

  // confMqtt
  else if (strcmp(param, "mqttenable") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_enable != tmpval)
    {
      confMqtt.mqtt_enable = tmpval;
      configChangedMqttConnResetRequired = true;
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "mqtthost") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_server) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_server, "", sizeof(confMqtt.mqtt_server));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_server, value, sizeof(confMqtt.mqtt_server));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "mqttport") == 0)
  {
    if (atoi(value) != confMqtt.mqtt_port)
    {
      confMqtt.mqtt_port = atoi(value);
      configChangedMqttConnResetRequired = true;
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "mqttuser") == 0)
  {
    if (strcmp(value, confSecrets.mqtt_user) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.mqtt_user, "", sizeof(confSecrets.mqtt_user));
        configChangedMqttConnResetRequired = true;
        confSecrets_wasChanged = true;
      }
      else
      {
        strlcpy(confSecrets.mqtt_user, value, sizeof(confSecrets.mqtt_user));
        configChangedMqttConnResetRequired = true;
        confSecrets_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "mqttpass") == 0)
  {
    if (strcmp(value, confSecrets.mqtt_pass) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confSecrets.mqtt_pass, "", sizeof(confSecrets.mqtt_pass));
        configChangedMqttConnResetRequired = true;
        confSecrets_wasChanged = true;
      }
      else
      {
        if (!strcmp(value, "****") == 0)
        {
          strlcpy(confSecrets.mqtt_pass, value, sizeof(confSecrets.mqtt_pass));
          configChangedMqttConnResetRequired = true;
          confSecrets_wasChanged = true;
        }
      }
    }
  }


  else if (strcmp(param, "intop") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_topic_in) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_topic_in, "", sizeof(confMqtt.mqtt_topic_in));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_topic_in, value, sizeof(confMqtt.mqtt_topic_in));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "outtop") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_topic_out) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_topic_out, "", sizeof(confMqtt.mqtt_topic_out));
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_topic_out, value, sizeof(confMqtt.mqtt_topic_out));
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "outret") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_outRetain != tmpval)
    {
      confMqtt.mqtt_outRetain = tmpval;
      confMqtt_wasChanged = true;
      if (tmpval == false)
      {
        publishDeleteRetainedOutMessages();
      }
    }
  }


  else if (strcmp(param, "outretsens") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_outRetain_sensors != tmpval)
    {
      confMqtt.mqtt_outRetain_sensors = tmpval;
      confMqtt_wasChanged = true;
      if (tmpval == false)
      {
        publishDeleteRetainedOutMessages_sensors();
      }
    }
  }


  else if (strcmp(param, "outpubint") == 0)
  {
    if (atoi(value) != confMqtt.mqtt_outPubInterval)
    {
      confMqtt.mqtt_outPubInterval = atoi(value);
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "outpubintsens") == 0)
  {
    if (atoi(value) != confMqtt.mqtt_outPubInterval_sensors)
    {
      confMqtt.mqtt_outPubInterval_sensors = atoi(value);
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "willtop") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_willTopic) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_willTopic, "", sizeof(confMqtt.mqtt_willTopic));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_willTopic, value, sizeof(confMqtt.mqtt_willTopic));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "willqos") == 0)
  {
    int tmpval = atoi(value);
    if (tmpval != confMqtt.mqtt_willQos)
    {
      if (tmpval >= 0 && tmpval <= 2)
      {
        confMqtt.mqtt_willQos = tmpval;
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "willret") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_willRetain != tmpval)
    {
      confMqtt.mqtt_willRetain = tmpval;
      configChangedMqttConnResetRequired = true;
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "willmsg") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_willMsg) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_willMsg, "", sizeof(confMqtt.mqtt_willMsg));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_willMsg, value, sizeof(confMqtt.mqtt_willMsg));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "connmsg") == 0)
  {
    if (strcmp(value, confMqtt.mqtt_connMsg) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confMqtt.mqtt_connMsg, "", sizeof(confMqtt.mqtt_connMsg));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
      else
      {
        strlcpy(confMqtt.mqtt_connMsg, value, sizeof(confMqtt.mqtt_connMsg));
        configChangedMqttConnResetRequired = true;
        confMqtt_wasChanged = true;
      }
    }
  }


  else if (strcmp(param, "hbenable") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_enable_heartbeat != tmpval)
    {
      confMqtt.mqtt_enable_heartbeat = tmpval;
      confMqtt_wasChanged = true;
    }
  }


  else if (strcmp(param, "hbreconn") == 0)
  {
    unsigned int _tmpval = atoi(value);
    if (_tmpval != confMqtt.mqtt_heartbeat_maxage_reconnect)
    {
      if (_tmpval == 0)
      {
        confMqtt.mqtt_heartbeat_maxage_reconnect = 0;
        confMqtt_wasChanged = true;
      }
      else if (_tmpval >= 1 && _tmpval <= 60)
      {
        confMqtt.mqtt_heartbeat_maxage_reconnect = _tmpval;
        confMqtt_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }


  else if (strcmp(param, "hbreboot") == 0)
  {
    unsigned int _tmpval = atoi(value);
    if (_tmpval != confMqtt.mqtt_heartbeat_maxage_reboot)
    {
      if (_tmpval == 0)
      {
        confMqtt.mqtt_heartbeat_maxage_reboot = 0;
        confMqtt_wasChanged = true;
      }
      else if (_tmpval >= 5 && _tmpval <= 3600)
      {
        confMqtt.mqtt_heartbeat_maxage_reboot = _tmpval;
        confMqtt_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }


  else if (strcmp(param, "reconsilent") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confMqtt.mqtt_reconnect_silent != tmpval)
    {
      confMqtt.mqtt_reconnect_silent = tmpval;
      confMqtt_wasChanged = true;
    }
  }


  // confAdd
  else if (strcmp(param, "outtemptop") == 0)
  {
    if (strcmp(value, confAdd.outTemp_topic_in) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confAdd.outTemp_topic_in, "", sizeof(confAdd.outTemp_topic_in));
        configChangedMqttConnResetRequired = true;
        confAdd_wasChanged = true;
      }
      else
      {
        strlcpy(confAdd.outTemp_topic_in, value, sizeof(confAdd.outTemp_topic_in));
        configChangedMqttConnResetRequired = true;
        confAdd_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "outhumtop") == 0)
  {
    if (strcmp(value, confAdd.outHum_topic_in) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confAdd.outHum_topic_in, "", sizeof(confAdd.outHum_topic_in));
        configChangedMqttConnResetRequired = true;
        confAdd_wasChanged = true;
      }
      else
      {
        strlcpy(confAdd.outHum_topic_in, value, sizeof(confAdd.outHum_topic_in));
        configChangedMqttConnResetRequired = true;
        confAdd_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "pirtop") == 0)
  {
    if (strcmp(value, confAdd.mqtt_topic_pir) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confAdd.mqtt_topic_pir, "", sizeof(confAdd.mqtt_topic_pir));
        confAdd_wasChanged = true;
      }
      else
      {
        strlcpy(confAdd.mqtt_topic_pir, value, sizeof(confAdd.mqtt_topic_pir));
        confAdd_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "pironpld") == 0)
  {
    if (strcmp(value, confAdd.mqtt_payload_pir_on) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confAdd.mqtt_payload_pir_on, "", sizeof(confAdd.mqtt_payload_pir_on));
        confAdd_wasChanged = true;
      }
      else
      {
        strlcpy(confAdd.mqtt_payload_pir_on, value, sizeof(confAdd.mqtt_payload_pir_on));
        confAdd_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "piroffpld") == 0)
  {
    if (strcmp(value, confAdd.mqtt_payload_pir_off) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confAdd.mqtt_payload_pir_off, "", sizeof(confAdd.mqtt_payload_pir_off));
        confAdd_wasChanged = true;
      }
      else
      {
        strlcpy(confAdd.mqtt_payload_pir_off, value, sizeof(confAdd.mqtt_payload_pir_off));
        confAdd_wasChanged = true;
      }
    }
  }

#ifdef ENABLE_FEATURE_NTP_TIME
  // confTime
  else if (strcmp(param, "tzstr") == 0)
  {
    if (strcmp(value, confTime.timeZoneStr) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTime.timeZoneStr, "", sizeof(confTime.timeZoneStr));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
      else
      {
        strlcpy(confTime.timeZoneStr, value, sizeof(confTime.timeZoneStr));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "ntpenable") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confTime.ntpEnable != tmpval)
    {
      confTime.ntpEnable = tmpval;
      configChangedRestartRequired = true;
      confTime_wasChanged = true;
    }
  }

  else if (strcmp(param, "ntpserver1") == 0)
  {
    if (strcmp(value, confTime.ntpServer1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTime.ntpServer1, "", sizeof(confTime.ntpServer1));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
      else
      {
        strlcpy(confTime.ntpServer1, value, sizeof(confTime.ntpServer1));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "ntpserver2") == 0)
  {
    if (strcmp(value, confTime.ntpServer2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTime.ntpServer2, "", sizeof(confTime.ntpServer2));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
      else
      {
        strlcpy(confTime.ntpServer2, value, sizeof(confTime.ntpServer2));
        configChangedRestartRequired = true;
        confTime_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "ntpsyncint") == 0)
  {
    unsigned int valueInt = atoi(value) * 60;
    if (confTime.ntpSyncInterval != valueInt)
    {
      confTime.ntpSyncInterval = valueInt;
      configChangedRestartRequired = true;
      confTime_wasChanged = true;
    }
  }
#endif // NTP

  // confLog
  else if (strcmp(param, "loglevser") == 0)
  {
    int valueInt = atoi(value);
    if (confLog.logLevelSerial != valueInt)
    {
      if (valueInt >= 0 && valueInt <= 5)
      {
        confLog.logLevelSerial = valueInt;
        confLog_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "loglevweb") == 0)
  {
    int valueInt = atoi(value);
    if (confLog.logLevelWeb != valueInt)
    {
      if (valueInt >= 0 && valueInt <= 5)
      {
        confLog.logLevelWeb = valueInt;
        confLog_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "loglevmqtt") == 0)
  {
    int valueInt = atoi(value);
    if (confLog.logLevelMqtt != valueInt)
    {
      if (valueInt >= 0 && valueInt <= 5)
      {
        confLog.logLevelMqtt = valueInt;
        confLog_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "logwebrequests") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confLog.logWebRequests != tmpval)
    {
      confLog.logWebRequests = tmpval;
      confLog_wasChanged = true;
    }
  }



  // DISPLAY
  else if (strcmp(param, "dispint") == 0)
  {
    int valueInt = atoi(value);
    if (valueInt != confDisplay.displayInterval)
    {
      if (valueInt >= 1 && valueInt <= 60)
      {
        confDisplay.displayInterval = valueInt;
        confDisplay_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
       sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "disptout") == 0)
  {
    int valueInt = atoi(value);
    if (valueInt != confDisplay.displayTimeout)
    {
      if (valueInt >= 2 && valueInt <= 3600)
      {
        confDisplay.displayTimeout = valueInt;
        confDisplay_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "pirendisp") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (tmpval != confDisplay.PIRenablesDisplay)
    {
      confDisplay.PIRenablesDisplay = tmpval;
      confDisplay_wasChanged = true;
    }
  }
  // /DISPLAY



  // SENSORS
  else if (strcmp(param, "measint") == 0)
  {
    int valueInt = atoi(value);
    if (valueInt != confSens.measureInterval)
    {
      if (valueInt >= 5 && valueInt <= 60)
      {
        confSens.measureInterval = valueInt;
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
       sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  #ifdef ENABLE_SENSOR_DHT22
    else if (strcmp(param, "dht_tempcorr") == 0)
    {
      float valueFloat = atof(value);
      if (valueFloat != confSens.DHT_tempCorrVal)
      {
        if (valueFloat >= -5.0 && valueFloat <= 5.0)
        {
          confSens.DHT_tempCorrVal = valueFloat;
          confSens_wasChanged = true;
        }
      }
    }
  
    else if (strcmp(param, "dht_humcorr") == 0)
    {
      int valueInt = atoi(value);
      if (valueInt != confSens.DHT_humCorrVal)
      {
        if (valueInt >= -40 && valueInt <= 40)
        {
          confSens.DHT_humCorrVal = valueInt;
          confSens_wasChanged = true;
        }
      }
    }
  #endif //ENABLE_SENSOR_DHT22
  
  #ifdef ENABLE_SENSORS_ONEWIRE
    // assign sensors - console commands
    else if (strcmp(param, "sens_feed") == 0)
    {
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(val, ONEWIRE_SENSOR_INDEX_FEED);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }

    else if (strcmp(param, "sens_return") == 0)
    {
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(val, ONEWIRE_SENSOR_INDEX_RETURN);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }

    else if (strcmp(param, "sens_out") == 0)
    {
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(val, ONEWIRE_SENSOR_INDEX_OUT);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }

    // assign sensors - from web interface
    else if (strcmp(param, "assignsens_0") == 0)
    { // value is index of confSens.oneWireDevAddress/oneWireSensor_assignedDevToIndex 
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(0, val);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
    // assign sensors - from web interface
    else if (strcmp(param, "assignsens_1") == 0)
    { // value is index of confSens.oneWireDevAddress/oneWireSensor_assignedDevToIndex 
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(1, val);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
    // assign sensors - from web interface
    else if (strcmp(param, "assignsens_2") == 0)
    { // value is index of confSens.oneWireDevAddress/oneWireSensor_assignedDevToIndex 
      int val = atoi(value);
      if (val >= 0 && val <= ONEWIRE_SENSORS_COUNT)
      {
        oneWireSensor_assign(2, val);
        confSens_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  #endif // ENABLE_SENSORS_ONEWIRE
  // /SENSORS - confSens
  

  
  // THERMOSTAT - confTherm
  #ifdef FIRMWARE_VARIANT_THERMOSTAT
  else if (strcmp(param, "autosavetemp") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confTherm.autoSaveSetTemp != tmpval)
    {
      confTherm.autoSaveSetTemp = tmpval;
      confTherm_wasChanged = true;
    }
  }

  else if (strcmp(param, "autosavemode") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confTherm.autoSaveHeatingMode != tmpval)
    {
      confTherm.autoSaveHeatingMode = tmpval;
      confTherm_wasChanged = true;
    }
  }

  else if (strcmp(param, "savetomqttret") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (confTherm.saveToMqttRetained != tmpval)
    {
      confTherm.saveToMqttRetained = tmpval;
      confTherm_wasChanged = true;
      if (tmpval == false)
      {
        publishDeleteRetainedSavedStates();
      }
    }
  }

  else if (strcmp(param, "tempmin") == 0)
  {
    float valueFloat = round(atof(value) * 2.0) / 2.0;
    if (valueFloat != confTherm.setTempMin)
    {
      if (valueFloat >= 10 && valueFloat <= 16)
      {
        confTherm.setTempMin = valueFloat;
        confTherm_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "tempmax") == 0)
  {
    float valueFloat = round(atof(value) * 2.0) / 2.0;
    if (valueFloat != confTherm.setTempMax)
    {
      if (valueFloat >= 18 && valueFloat <= 30)
      {
        confTherm.setTempMax = valueFloat;
        confTherm_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "pirendispps0") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (tmpval != confTherm.PIRenablesDisplay_preset0only)
    {
      confTherm.PIRenablesDisplay_preset0only = tmpval;
      confTherm_wasChanged = true;
    }
  }

  else if (strcmp(param, "togthdisp") == 0)
  {
    bool tmpval;
    if (atoi(value) == 1)
      tmpval = true;
    else
      tmpval = false;

    if (tmpval != confTherm.togglingTempHumAIDisplay)
    {
      confTherm.togglingTempHumAIDisplay = tmpval;
      confTherm_wasChanged = true;
    }
  }

  // confThermAdv
  else if (strcmp(param, "minofftime") == 0)
  {
    int valueInt = atoi(value);
    if (valueInt != confTherm.heatingMinOffTime)
    {
      confTherm.heatingMinOffTime = valueInt;
      confTherm_wasChanged = true;
    }
  }

  else if (strcmp(param, "tempdec") == 0)
  {
    float valueFloat = atof(value);
    if (valueFloat != confTherm.setTempDecreaseVal)
    {
      if (valueFloat >= 0.0 && valueFloat <= 1.5)
      {
        confTherm.setTempDecreaseVal = valueFloat;
        confTherm_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "hyst") == 0)
  {
    float valueFloat = atof(value);
    if (valueFloat != confTherm.hysteresis)
    {
      if (valueFloat >= 0.1 && valueFloat <= 4.0)
      {
        confTherm.hysteresis = valueFloat;
        confTherm_wasChanged = true;
      }
      else {
        sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
        sendLog(logBuf, LOGLEVEL_ERROR);
      }
    }
  }

  else if (strcmp(param, "offmsg") == 0)
  {
    if (strcmp(value, confTherm.offMessage) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.offMessage, "", sizeof(confTherm.offMessage));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.offMessage, value, sizeof(confTherm.offMessage));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "modename0") == 0)
  {
    if (strcmp(value, confTherm.modeName0) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.modeName0, "", sizeof(confTherm.modeName0));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.modeName0, value, sizeof(confTherm.modeName0));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "modename1") == 0)
  {
    if (strcmp(value, confTherm.modeName1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.modeName1, "", sizeof(confTherm.modeName1));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.modeName1, value, sizeof(confTherm.modeName1));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "psetname0") == 0)
  {
    if (strcmp(value, confTherm.psetName0) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.psetName0, "", sizeof(confTherm.psetName0));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.psetName0, value, sizeof(confTherm.psetName0));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "psetname1") == 0)
  {
    if (strcmp(value, confTherm.psetName1) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.psetName1, "", sizeof(confTherm.psetName1));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.psetName1, value, sizeof(confTherm.psetName1));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "psetname2") == 0)
  {
    if (strcmp(value, confTherm.psetName2) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.psetName2, "", sizeof(confTherm.psetName2));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.psetName2, value, sizeof(confTherm.psetName2));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "itemplab") == 0)
  {
    if (strcmp(value, confTherm.iTempLabel) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.iTempLabel, "I", sizeof(confTherm.iTempLabel));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.iTempLabel, value, sizeof(confTherm.iTempLabel));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "otemplab") == 0)
  {
    if (strcmp(value, confTherm.oTempLabel) != 0)
    {
      if (strcmp(value, "0") == 0)
      {
        strlcpy(confTherm.oTempLabel, "O", sizeof(confTherm.oTempLabel));
        confTherm_wasChanged = true;
      }
      else
      {
        strlcpy(confTherm.oTempLabel, value, sizeof(confTherm.oTempLabel));
        confTherm_wasChanged = true;
      }
    }
  }

  else if (strcmp(param, "pausetout") == 0)
  {
    int valueInt = atoi(value);
    if (valueInt != confTherm.pauseTout)
    {
      if (valueInt >= 0 && valueInt <= 3600)
      {
        confTherm.pauseTout = valueInt;
        confTherm_wasChanged = true;
      }
      else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
    }
  }

  // Thermostat values
  else if (strcmp(param, "temp") == 0)
  {
    float valueFloat = round(atof(value) * 2.0) / 2.0;
    thermostat_setTempTo(valueFloat);
  }
  
  else if (strcmp(param, "templow") == 0)
  {
    float valueFloat = round(atof(value) * 2.0) / 2.0;
    thermostat_setTempLowTo(valueFloat);
  }
  
  else if (strcmp(param, "templow2") == 0)
  {
    float valueFloat = round(atof(value) * 2.0) / 2.0;
    thermostat_setTempLow2To(valueFloat);
  }
  
  else if (strcmp(param, "mode") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 1)
    {
      thermostat_setHeatingmodeTo(val);
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }
  
  else if (strcmp(param, "preset") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 2)
    {
      thermostat_setPresetTo(val);
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }
  #endif // FIRMWARE_VARIANT_THERMOSTAT
  // /THERMOSTAT



  // HEAT CONTROL - confHeatc
  #ifdef FIRMWARE_VARIANT_HEATCONTROL
  else if (strcmp(param, "heatcm20") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[0] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatcm15") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[1] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatcm10") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[2] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatcm5") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[3] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatc0") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[4] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatc5") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[5] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatc10") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[6] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatc15") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[7] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatc20") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatCurve[8] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }


  else if (strcmp(param, "heatlm20") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[0] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatlm15") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[1] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatlm10") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[2] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatlm5") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[3] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatl0") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[4] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatl5") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[5] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatl10") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[6] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatl15") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[7] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatl20") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.heatLocktime[8] = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatusehc") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 1)
    {
      if (val == 1) confHeatc.useHeatCurve = true;
      else confHeatc.useHeatCurve = false;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatforcehc") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 1)
    {
      if (val == 1) confHeatc.forceHeatCurve = true;
      else confHeatc.forceHeatCurve = false;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatcvhy1") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 10)
    {
      confHeatc.hystereseOn = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatcvhy0") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 16)
    {
      confHeatc.hystereseOff = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  

  else if (strcmp(param, "pumpnl") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 90)
    {
      confHeatc.pumpBacklash = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heattempfeedlimit") == 0)
  {
    int val = atoi(value);
    if (val >= 50 && val <= 90)
    {
      confHeatc.tempFeedLimit = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatouttdis") == 0)
  {
    int val = atoi(value);
    if (val >= 16 && val <= 26)
    {
      confHeatc.disableAboveTOut = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "heatforcehcalsoon") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 1)
    {
      if (val == 1) confHeatc.forceHeatCurveAlsoForSwitchOn = true;
      else confHeatc.forceHeatCurveAlsoForSwitchOn = false;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "pumpforceint") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 255)
    {
      confHeatc.pump_forceRunInterval = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "pumpforcetime") == 0)
  {
    int val = atoi(value);
    if (val >= 1 && val <= 15)
    {
      confHeatc.pumpTime_forceRun = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "pumpforcebegin") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 23)
    {
      confHeatc.pump_forceRunTimeBegin = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  else if (strcmp(param, "pumpforceend") == 0)
  {
    int val = atoi(value);
    if (val >= 0 && val <= 24)
    {
      confHeatc.pump_forceRunTimeEnd = val;
      confHeatc_wasChanged = true;
    }
    else {
      sprintf_P(logBuf, PGMStr_conf_invalidValue, param);
      sendLog(logBuf, LOGLEVEL_ERROR);
    }
  }

  #endif //FIRMWARE_VARIANT_HEATCONTROL



  else {
    snprintf_P(logBuf, LOG_BUFFER_SIZE, PGMStr_conf_setConf_unknownParamName, param);
    sendLog(logBuf);
  }


  //getConfig(param);
  
  if (confCheckUnsaved())
  {
    lastConfigChange = millis();
    lastConfigChangeNoteAlreadyDone = false;
  }
} // setConfig()