tony-fav / tasmota-blerry

GNU General Public License v3.0
96 stars 29 forks source link

Add BlerryConfigURL to auto download the config #56

Closed vaparr closed 1 year ago

vaparr commented 2 years ago

Added config option BlerryConfigURL to set the URL to download the config file from. This will update at every boot.

vaparr commented 2 years ago

Example:

BlerryConfigURL https://raw.githubusercontent.com/MyRepo/blerry/main/blerry_config.json

Will create a blerry_configurl.txt with the URL, and when loading the config, we will check to see if the file is accessible, and valid json; then place the file on the FS as blerry_config.json

restart 1 after setting the URL

tony-fav commented 2 years ago

This looks like a pretty useful feature but there seems to be a good bit of bulk.

Have you looked at storing the config URL via the berry persist module? This would prevent having to do even more manual file io.

Why not use the download_file function instead duplicating code?

Only worried about code size because of how difficult it is to get the blerry.be onto ESP32 consistently already.

vaparr commented 2 years ago

Switched to using the persist module.

The reason i didnt use download_file() is because i wanted to validate the file was valid json, before potentially overwriting a working config. Should i just blindly download the file instead, or maybe modify download_file to validate the json if it ends in .json?

tony-fav commented 2 years ago

@vaparr are you happy with it now? I plan to (like next weekend) deploy a few Switchbot plugs and that would give me a chance to test this out without disrupting anything (don't have an extra board setup for testing at the moment 😅), but I can go ahead and merge this now. Will clean up some duplicate things myself and hopefully do a "main" pull and release soon.

vaparr commented 2 years ago

@tony-fav Yep. Im running it on 8 switchbot bulbs, and seems to be working good.

tony-fav commented 1 year ago

Apologies, never got around to this, merging now cause it's a nifty feature. Thanks!