[GH-ISSUE #1510] Checkbox startup values #1290

Open
opened 2026-02-28 01:29:26 +03:00 by kerem · 2 comments
Owner

Originally created by @AJTaylor79 on GitHub (Oct 13, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1510

I seem to be having an issue with Checkbox startup values.

The file loads ok with the true/false value for the value of the checkbox however the variable that reference these always returns a 1.

As example emoncms_enable loads as false, goes through this routine as always returns a 1, this only happens on startup rather than if I go into the ondemand portal and change the values, they then seem to work ok.

Any idea what the issue could be?

Thanks for your help

Andrew

Sketch

#BEGIN
  char customHtml_checkbox[] = "type=\"checkbox\"";
    if (emoncms_enable) {
      strcat(customHtml_checkbox, " checked");
    }
   WiFiManagerParameter custom_emoncms_enable_checkbox("emoncms_enable", "Enable Emoncms", "T", 2, customHtml_checkbox, WFM_LABEL_AFTER);
   char customHtml_checkbox_2[] = "type=\"checkbox\"";
     if (mqtt_enable) {
      strcat(customHtml_checkbox_2, " checked");
    }
  WiFiManagerParameter custom_mqtt_enable_checkbox("mqtt_enable", "Enable MQTT", "T", 2, customHtml_checkbox_2, WFM_LABEL_AFTER);

  emoncms_enable = (strncmp(custom_emoncms_enable_checkbox.getValue(), "T", 1) == 0);
  mqtt_enable = (strncmp(custom_mqtt_enable_checkbox.getValue(), "T", 1) == 0);


#END

Debug Messages

messages here
Originally created by @AJTaylor79 on GitHub (Oct 13, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1510 I seem to be having an issue with Checkbox startup values. The file loads ok with the true/false value for the value of the checkbox however the variable that reference these always returns a 1. As example emoncms_enable loads as false, goes through this routine as always returns a 1, this only happens on startup rather than if I go into the ondemand portal and change the values, they then seem to work ok. Any idea what the issue could be? Thanks for your help Andrew ### Sketch ```cpp #BEGIN char customHtml_checkbox[] = "type=\"checkbox\""; if (emoncms_enable) { strcat(customHtml_checkbox, " checked"); } WiFiManagerParameter custom_emoncms_enable_checkbox("emoncms_enable", "Enable Emoncms", "T", 2, customHtml_checkbox, WFM_LABEL_AFTER); char customHtml_checkbox_2[] = "type=\"checkbox\""; if (mqtt_enable) { strcat(customHtml_checkbox_2, " checked"); } WiFiManagerParameter custom_mqtt_enable_checkbox("mqtt_enable", "Enable MQTT", "T", 2, customHtml_checkbox_2, WFM_LABEL_AFTER); emoncms_enable = (strncmp(custom_emoncms_enable_checkbox.getValue(), "T", 1) == 0); mqtt_enable = (strncmp(custom_mqtt_enable_checkbox.getValue(), "T", 1) == 0); #END ``` ### Debug Messages ``` messages here ```
Author
Owner

@AJTaylor79 commented on GitHub (Nov 26, 2022):

Has anyone got any thoughts on this as I would love to get it working? @tablatronix thanks

<!-- gh-comment-id:1328035105 --> @AJTaylor79 commented on GitHub (Nov 26, 2022): Has anyone got any thoughts on this as I would love to get it working? @tablatronix thanks
Author
Owner

@mylms commented on GitHub (Apr 28, 2025):

I have the same issue. I have same code - ussualy works good, bud sometimes some checkbox (or all chbxs) are checked. I have to uncheck all in config portal and save.
Did you solve it?

<!-- gh-comment-id:2836634532 --> @mylms commented on GitHub (Apr 28, 2025): I have the same issue. I have same code - ussualy works good, bud sometimes some checkbox (or all chbxs) are checked. I have to uncheck all in config portal and save. Did you solve it?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1290
No description provided.