apply new settings while DIA is running


I have a DIA application running on a ConnectPort X4. Some operations involve modifying the settings (i.e. changing the dia.yml file) and I would like to apply the new settings to my custom device drivers.

I tried calling load(‘WEB/python/dia.yml’) on the CoreServices instance to reload the file and get the new settings applied to all running drivers. The apply_settings method of my driver gets called, but I always get the old settings.

What am I doing wrong?


Unfortunately, the folks who created this stuff didn’t think any sane person would want to reload their settings, so it wasn’t designed to be done. They expect you to reboot the gateway.

One possible problem - if the ‘WEB/python/dia.pyr’ file exists, it might be prefering that. Try deleting that file first.

Also, look for a file named - might be in your src\devices directory. Not sure which rev of Dia had this added. Anyway, this file does something a bit different - it allows the custom driver to both apply & use, plus SAVE settings out to the dia.pyr file, which means after a reboot you retain your changed settings.

Thanks for your response lynnl.

OK, then I must assume that the contents of the dia.yml file is cached somehow, and not reparsed on demand.

I’m not using the standard way of dealing with dia.yml files so I never have a dia.pyr in WEB/python. What I do is I have a base yml file that I combine with other yml files to create the dia.yml on program startup. I do this to keep configuration files for different purposes in separate files so it’s easier to manage, and more unlikely that a program (or hardware) failure breaks the whole configuration.

I’m running DIA 1.3.19 which is not the latest version according to what is presented by the ESP, the latest would be 1.4.6, correct? Is there a big difference between these versions? The latter is not advertised much by Digi, is there a reason, is it beta stuff or something the like?

I noticed the file is not in 1.3.19 but it is in 1.4.6. It gives some insight on how updating settings can be done, so it can probably give me the inspiration I needed to work around the issues I’m having, thanks for pointing this one out.

Let me know your thoughts about the DIA version. Thanks!

There is also a dia.pyr in the - it is possible the load command is just reloading that since it’s supposed to the same as the dia.yml, but 400K of RAM easier to parse.

If you are loading up your own, you could make sure there is no dia.yml or dia.pyr inside. This would force use of the external text dia.yml you are adjusting.

The other possibility is just use your own config file for things your driver needs to make static. For example, i often just save a str() of a dictionary as a text file recording for example external machine run-time in hours, etc. Then reading it in, passing it through eval() allows the driver to recover its state after a reboot.


Thanks for sharing your ideas, and a special thank you for bringing my attention to the module, it helped me figure out a way to work around my problem.

Here’s what I do to apply new settings:

  1. I get a handle on core_services, then a handle on the device_driver_manager like so:
deviceDriverManager = coreServices.get_service("device_driver_manager")
  1. Set the new settings:
deviceDriverManager.instance_setting_set( deviceInstanceName, "settingName", settingValue)
  1. Apply the settings and restart the driver:

Of course, the driver needs to support this workflow. Because I use this on custom device drivers it wasn’t a big deal.

Thanks again, and I hope it helps other too!