How can I get the name or package key from config.yml at runtime?

I want to set some values depending on what driver I’m running (I’ll have TEST and PROD versions of the same code). Is there a way I can get either the name value from config.yml or the packagekey value at runtime? I see Log.Info displays the name value when logging, so I know it’s out there somewhere. I dumped the driver table/object and nothing there that I can see.

Hi, @edleno

This is interesting, could you provide more info regarding your use case, please?

I’ve got an Edge LAN driver that I’m working on. It’s a valve with two remote switches that you can press to set the valve to send oxygen to that room (wife is on supplemental oxygen). So in “production” there are a total of three ESP32 devices - the valve controller that is located at the oxygen source, and two remote ESP32 devices that have a touch switch that indicates she is in a room and want the oxygen directed to that room. All communication is UDP on WiFi.

While developing I have two test ESP32 devices in my office. So, I don’t want to effect the “production” devices, so for example, all of the “test” devices use a different UDP port for discovery and communication.

I’d like my LUA driver to check if the packagekey contains “TEST” and if so, then use the UDP port for the test devices (name would also suffice). There would be two drivers on my hub - one with TEST in the name, and one with PROD in the name. So, I can test in my office with no chance of impacting the PROD devices.

Ideally this would just be a value I added to config.yml so I could have a different git branch for TEST and PROD and the only difference would be the name, packagekey, and prod/test signal. I believe I have to change the packagekey in order to have two copies on the hub at the same time - though somewhere versioning would come in and there COULD be multiple versions on the hub, but still have to address how discovery only discovers devices that I’ve configured for TEST.

Just to clarify, does this mean that they can only connect to the “test” driver or they can also be discovered by the “production” driver?

This is because:

  1. Yes, if you’re the owner of both drivers and they are in the same driver channel, they need to have a different packageKey.
  2. However, if you only update the “test” driver, it will only affect those devices, not the ones in “production”. They are treated separately.
  3. What I’ve seen is that others create separate channels (one for tests, and one for real devices). So the changes affect only the test driver and not the other one.

For these scenarios I would pick up another hub on ebay used. 2nd gen (wired only) for ~$25. Then you can install specific versions to whatever hub you want to. Works great.