Search found 55 matches

by ebolisa
Fri Nov 05, 2021 6:56 pm
Forum: General Discussion and Questions
Topic: mqtt_as connections issues
Replies: 2
Views: 1625

mqtt_as connections issues

@pythoncoder Hi Peter, I read somewhere you prefer be contacted via this forum regarding any issues with mqtt_as. As I mentioned on my last post, I'm working on a project where I'm using wifimgr to make the ESP32 module mobile, OTA to update the code and mqtt to communicate with node-red. So, I've b...
by ebolisa
Thu Nov 04, 2021 5:52 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

Regarding your query about handling existing connections, @kevinkk525 is working on a PR to expand the connection options. Short of modifying the code, one option is to deliberately disconnect when your application starts so that mqtt_as always starts in a known disconnected state. Thank you. Will ...
by ebolisa
Thu Nov 04, 2021 5:49 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

OlivierLenoir wrote:
Thu Nov 04, 2021 5:13 pm
Instead of having a config.py, you should have a config.json file.
Thanks, will look at it tomorrow as my brain cells are burnt out for the day.
by ebolisa
Thu Nov 04, 2021 5:11 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

FYI, The wifimgr lib creates a file (wifi.dat) and fills it with the new router's credentials. From main I read said credencials with ssid = '' wifi_pw = '' # get new wifi credentials with open("wifi.dat") as f: lines = f.readlines() for line in lines: ssid, wifi_pw = line.strip("\n").split(";") and...
by ebolisa
Thu Nov 04, 2021 3:18 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

Programmatically changing your custom dict would then be very easy: load the JSON dict, modify it, and save again. OK. Writing, reading and updating seems easy using json but still having an issue with config.py. How do I read it as a json file? This code fails: def r_json(mode): with open("config....
by ebolisa
Thu Nov 04, 2021 1:19 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

Programmatically changing your custom dict would then be very easy: load the JSON dict, modify it, and save again. Thanks for getting back to me and for sharing your mqtt_as lib. Yes, that makes sense and having a better understanding now of how the variables are passed to the library, will give it...
by ebolisa
Thu Nov 04, 2021 9:54 am
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file [solved]

Solution: import io, re filename = "config.py" # open file for reading my_file = open(filename) # read file's entire content #content = my_file.read() #my_file.close() #print('Original file content:') #print(content) pat = re.compile(r"^config\[\'([^']*)\'\]") def trans(line, dic): match = pat.match...
by ebolisa
Thu Nov 04, 2021 1:01 am
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Re: Updating a config file

I know but the config.py is not mine. Comes with the mqtt_as lib.
by ebolisa
Wed Nov 03, 2021 11:00 pm
Forum: General Discussion and Questions
Topic: Updating a config file [solved]
Replies: 12
Views: 4982

Updating a config file [solved]

Hi, I've a config.py file with the following content: from mqtt_as import config config['ssid'] = 'my router' config['ssid_pw'] = 'pwd' config['mqtt_user'] = 'user' config['mqtt_pw'] = 'pwd' config['pub_topic'] = 'main/esp' config['sub_topic'] = 'main/esp/32/relays I know how to read from it but how...
by ebolisa
Mon Nov 01, 2021 10:02 pm
Forum: General Discussion and Questions
Topic: OTA revisited [solved]
Replies: 0
Views: 811

OTA revisited [solved]

Hi, I trying to use the repository at https://github.com/rdehuyss/micropython-ota-updater and I'm getting the following error: Memory free 81872 Checking version... Current version: 0.6.1 Latest version: 1.0.0 Updating to version 1.0.0... Downloading version 1.0.0 URL: https://api.github.com/repos/e...