homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

Help with editing JSON configuration? #281

Closed aamoroso closed 7 years ago

aamoroso commented 7 years ago

Hi,

I am using version 1.5.0 with Arduino IDE 1.6.12. I have a small sketch using Homie. It is pretty much identical to the light switch example. My code works fine, but I have a pre-existing JSON configuration file which I want to change. I cannot get the configuration file to go away. Reflashing the sketch doesn't affect it (which I have read is as per normal). But I assumed putting the ESP into boot loader mode would override it and put Homie back into configuration mode... but I don't seem able to do that. Is it possible to edit the file some way? ESPexplorer doesn't seem to be able to do anything and I can't get the ESP8266FS tool in the IDE to even come up.

Many thanks, Adrian

UPDATE: I got rid of the config.json file by holding the FLASH button for 5 seconds while it was booting. It would be nice to know if there was a way to edit it, however :)

brodtm commented 7 years ago

You can call Interface::get().getConfig().erase(); in order to erase the json file.

aamoroso commented 7 years ago

Thanks, brodtm. I should have thought of doing it programatically :)

EDIT: And in case anyone else is interested the other way of editing (or even setting initially) the configuration file is via the Ardiono IDE.

Put the config file into ~/Arduino//data/homie/config.json and (whilst in the actual sketch) choose from the menu, 'ESP8266 Sketch Data Upload'. On some boards, you have to ensure the board is in boot loader mode first (eg ESP1, Adafruit Huzzah, etc - some prototype boards don't need it). It takes a couple minutes.

marvinroger commented 7 years ago

Glad you solved your issue, feel free to reopen if needed!