On 05 Feb 2016, at 23:46, Dirk-Willem van Gulik <dirkx@webweaving.org> wrote:

We have a tiny sensor/discovery module (gist below) that picks up the (back)pressure, in Bar, of a cooling system.

However when we add below to config.php:

$config['sensor_types']['pressure']['symbol']='B';
$config['sensor_types']['pressure']['text']='Pressure';
$config['sensor_types']['pressure']['icon']=‘oicon-omega’;

it seems that these values are wiped/overwritten by the values from definitions.dat.

What, or perhaps, where, is the proper way to add these ?


To refine this a bit more - when we add above to config.php along with an entry config[silly]=test; we see below [1] in http://10.11.0.132/settings/format=changed_config/.

Pretty much as you’d expect. 

On http://10.11.0.132/settings/format=config/ we see ‘test-silly (second screenshot) - confirming that this shows the full set of data.

Sofar so good.  However if we scroll to sensor types - we do NOT see the extra 2 entries from config.php (screenshot 3).

So something is amiss here.

However if we move these entries to definitions.inc.php - post the reading of definitions.dat - all is well again (screenshot 4).

So I guess the bug is in the array merge. 

Tiny  SVN patch attached below.. I suspect it may be worthwhile to poke a bit more at this - as some issues with the detected mibs posted about half a year ago smell the same.

Dw.

beeb:includes dirkx$ svn diff
Index: definitions.inc.php
===================================================================
--- definitions.inc.php
+++ definitions.inc.php (working copy)
@@ -146,7 +146,7 @@
   //var_dump($config_tmp);
   if (is_array($config_tmp) && isset($config_tmp['os'])) // Simple check for passed correct data
   {
-    $config = array_merge($config, $config_tmp);
+    $config = array_merge_recursive($config, $config_tmp);
   }
   unset($config_tmp);
 }