Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty value handling #242

Closed
jfrogg opened this issue Mar 20, 2017 · 7 comments
Closed

empty value handling #242

jfrogg opened this issue Mar 20, 2017 · 7 comments
Labels
question Type - Asking for Information

Comments

@jfrogg
Copy link

jfrogg commented Mar 20, 2017

I have a few parameters in user_config.h which are left empty, for example:
#define MQTT_USER "" // [MqttUser] Optional user
#define MQTT_PASS "" // [MqttPassword] Optional password
#define NTP_SERVER2 "" // [NtpServer2] Select second NTP server by name or IP address (5.39.184.5)
#define NTP_SERVER3 "" // [NtpServer3] Select third NTP server by name or IP address (93.94.224.67)

This empty settings will be reflected in the actual device configuration, so no problem yet.
If I will ever upgrade using the pre-complied image from github zip I will see such parameters overridden by defaults like "DVES_USER" for MQTT username, etc.
Is that an intended behavior? From my perspective my empty values should be preserved as all others.

And a side question - is it possible to clear (or set empty) values from console or via MQTT? If yes - what's the syntax then? Using "" will produce """".

@arendst
Copy link
Owner

arendst commented Mar 20, 2017

Have you tried to upgrade using a pre-compiled image and did you notice the behaviour you expect?

@arendst arendst added the question Type - Asking for Information label Mar 20, 2017
@jfrogg
Copy link
Author

jfrogg commented Mar 20, 2017

@arendst This is what I'm saying - after upgrading from user-compiled to pre-compiled image from github my empty defaults got overridden by your defaults. As I recall from my last night testing, MQTT_USER and MQTT_PASS were overridden while NTP_SERVER2 and NTP_SERVER3 were not.
I can re-test again if necessary, just give me instructions. Thanks!

@arendst
Copy link
Owner

arendst commented Mar 20, 2017

No need to test. I'll check

@arendst arendst added the bug Type - Confirmated Bug label Mar 20, 2017
@arendst
Copy link
Owner

arendst commented Mar 21, 2017

Two items to discuss.

Resetting your previous empty values after loading the pre-compiled image is expected as long as your CFG_HOLDER define is different from the pre-compiled define. In that case all settings are reset to the pre-compiled values. If you want them to stay as you like you will have to reset your CFG_HOLDER to the same value as the pre-compiled value. In that case your empty fields stay empty as no settings are reset.

About setting empty values via MQTT the only possible solution I see is sending a 0 for an empty field which I will translate to "".

@arendst arendst removed the bug Type - Confirmated Bug label Mar 21, 2017
arendst added a commit that referenced this issue Mar 21, 2017
4.0.8 20170321
* Fix entering non-numeric webpassword
* Force selection between TLS or Webserver due to memory restraint
(#240)
* Allow entering empty string using "0" for selected commands (#242)
* Fix exception when posting commands to web console containing % (#250)
@jfrogg
Copy link
Author

jfrogg commented Mar 21, 2017

Using zero for an empty value looks good for me.
Here is my test plan:

  1. compiled a binary with "#define CFG_HOLDER 0x20161209" and some empty values
  2. loaded that binary from the web gui
  3. "reset 1" from the console to load my defaults
  4. checking for empty values - all good
CMND: mqttuser
MQTT: stat/sonoff/RESULT = ["MqttUser":""}
  1. OTA with the github pre-compiled image
  2. checking for previously empty values - all good
  3. changing topic from sonoff to sonoff2
  4. checking for previously empty values - MqttUser is not empty anymore:
CMND: mqttuser
MQTT: stat/sonoff2/RESULT = ["MqttUser":"DVES_USER"}

BTW, what's the meaning of "DVES"?

@arendst
Copy link
Owner

arendst commented Mar 21, 2017

Do not forget to mention you do this all via the web interface as using the commands via console or MQTT will not do what you experience. Anyway. The latest release (4.0.8) should solve your problem.

Having a MQTTuser and/or password should not be any problem if you have configured your MQTT broker for not using MQTTuser and/or password so that's why no one raised the issue before.

The default names DVES_ stands for DeVice ESp8266 the processor chip inside sonoff and was used by my initial MQTT client designed by Tuan (https://github.com/tuanpmt/esp_mqtt).

@jfrogg
Copy link
Author

jfrogg commented Mar 21, 2017

MQTTuser value was taken as an example only as it was easily noticeable in the web gui. It's clear that your default username will not harm and now it could be even cleared by using zero value. Tested 4.0.8 - all looks good, thanks a lot!

@jfrogg jfrogg closed this as completed Mar 21, 2017
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
4.0.8 20170321
* Fix entering non-numeric webpassword
* Force selection between TLS or Webserver due to memory restraint
(arendst#240)
* Allow entering empty string using "0" for selected commands (arendst#242)
* Fix exception when posting commands to web console containing % (arendst#250)
arendst pushed a commit that referenced this issue Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Type - Asking for Information
Projects
None yet
Development

No branches or pull requests

2 participants