understanding mqtt_as configuration process #9709
-
|
Hi when I changed some of its behavior to better suits my need I moved some of the built in value of the config dict in mqtt_as.py to the config.py file in a similar way than ssid and password are handled in the original library. Can someone be kind enough to explain to me when and how the file config.py is read to update the corresponding value in the config dict? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
|
In the config.py module the config dictionary from mqtt_as is imported and values are assigned to some dictionary items. In the example config.py settings are made for the server the SSID and the wifi pw. I understand from your post you have expanded this to include some other config settings in this config.py file. In your main program file you must have imported the config.py file to enable all the settings in the config.py to take effect. Taking the example file clean.py as an example you can see the line: |
Beta Was this translation helpful? Give feedback.
-
|
Thanks guys |
Beta Was this translation helpful? Give feedback.
-
|
Again taking the clean.py example for using the mqtt_as library, the 'from mqtt_as import config' in this file is only necessary as the clean.py code makes assignments to the config dictionary itself, and not all assignments are made just in the config.py file (the config.py file also has 'from mqtt_as import config' so likewise it can make changes to the config dictionary. |
Beta Was this translation helpful? Give feedback.
-
|
I accept I made a mistake in naming the configuration file What is going on is as follows. A typical application starts with from mqtt_as import MQTTClient, configThis instantiates the from config import wifi_led, blue_ledis that The application then adds its own configuration details with lines like config['subs_cb'] = sub_cb
config['wifi_coro'] = wifi_han
config['will'] = (TOPIC, 'Goodbye cruel world!', False, 0)before instantiating the client with client = MQTTClient(config)Perhaps I should clarify this in the docs. |
Beta Was this translation helpful? Give feedback.
Again taking the clean.py example for using the mqtt_as library, the 'from mqtt_as import config' in this file is only necessary as the clean.py code makes assignments to the config dictionary itself, and not all assignments are made just in the config.py file (the config.py file also has 'from mqtt_as import config' so likewise it can make changes to the config dictionary.
Too many things named config in these examples I must agree and in my use of this very useful mqtt_as library I do use a config file but I name my file mqtt_as_ini.py instead of config.py so I don't get confused.