Excessive disk access from hue/deconz after OH upgrade

Don’t really know where to report this. Should I file a bug report in the Github bug tracker? And if so, would this be related to deconz or hue binding. Actually I am not even sure if this is a bug, or just an inconvenience because of my configuration.

After upgrading my OH installation to 2.5.6 (BTW also upgraded Deconz to 2.05.78), I started getting errors like the following from a backup script I am running nightly:

file has vanished: "/var/lib/openhab2/jsondb/backup/1593735966369--org.eclipse.smarthome.config.discovery.DiscoveryResult.json"
file has vanished: "/var/lib/openhab2/jsondb/backup/1593735966878--org.eclipse.smarthome.config.discovery.DiscoveryResult.json"

When I looked into this, it turned out a new file was being written twice per second. I stopped OH and diffed two files. I have some Xiaomi Aqara motion sensors connected to deconz. They are set up in deconz to turn off some lights, without involving OH at all. Hence I have not added the Things (just left them in the inbox). The only differences in the .json-files were some timestamps in items belonging to the motion sensor rules:

   "hue:0840:00212E04DEE1:27": {
     "class": "org.eclipse.smarthome.config.discovery.internal.DiscoveryResultImpl",
     "value": {
... CUT ...
       "properties": {
         "modelId": "PHOSCON_FSM_STATE",
         "uniqueId": "fsm-state-1593803551911",
         "sensorId": "27"
       },
       "representationProperty": "uniqueId",
       "flag": "NEW",
       "label": "FSM_STATE Holder Rebeccas lys tændt",
-      "timestamp": 1593803606943,
+      "timestamp": 1593803607451,
       "timeToLive": -1
     }
   },

I have removed the Phoscon Sensor Control rules, and the updates were reduced to every 10 seconds. The updates were now coming from the timestamps of Hue groups (which I have not been using in OH, they appeared after my OH upgrade). Here is a (slightly edited) diff:

   "hue:group:00212E04DEE1:5224": {
     "class": "org.eclipse.smarthome.config.discovery.internal.DiscoveryResultImpl",
     "value": {
... CUT ...
       "properties": {
         "groupId": "5224"
       },
       "representationProperty": "groupId",
       "flag": "NEW",
       "label": "TRADFRI wireless dimmer 9 (LightGroup)",
-      "timestamp": 1593798634926,
+      "timestamp": 1593798644951,
       "timeToLive": -1
     }
   }

This time I tried hiding them from the inbox, but that doesn’t solve the problem, they are still in the json-file, just with a new field indicating they are hidden. So I went ahead and added all those groups as Things in OH, and the file update interval is now down to 5 minutes:

   "deconz:dimmablelight:3d8ca982:90fd9ffffe2a576801": {
     "class": "org.eclipse.smarthome.config.discovery.internal.DiscoveryResultImpl",
     "value": {
... CUT ...
       "properties": {
         "uid": "90:fd:9f:ff:fe:2a:57:68-01",
         "id": "10",
         "firmwareVersion": "1.2.245",
         "modelId": "TRADFRI transformer 30W",
         "vendor": "IKEA of Sweden"
       },
       "representationProperty": "uid",
       "flag": "NEW",
       "label": "hobbyroom under shelf (IKEA of Sweden)",
-      "timestamp": 1593803932892,
+      "timestamp": 1593804232889,
       "timeToLive": -1
     }
   },

This now shows the deconz-Things (the lights are not added as Things in OH due to them also being available through the Hue binding).

Is this a bug, or working as designed? Luckily I am on a Debian box with an SSD, but even so creating a new file twice every second seems a little overwhelming. On a Raspberry Pi my guess would be that the SD-card could wear out quickly.

It seems go stop if I add all the stuff from the Inbox as Things. But is it otherwise bad to leave them in the Inbox?

For instance I have a bunch of lights set up with the Hue binding, but now also available through the Deconz-binding (which used to support only sensors). Should I migrate them all over to using the Deconz-binding and remove the Hue binding?

I think it might be a consequence of this PR:

For the rediscovery twice per second, it corresponds to the job for sensors. You can simply disable it by setting its interval to 0 in case you don’t use sensors through the hue binding.

For lights and groups, the job is by defaut run every 10 seconds.

Before this PR, I think the discovery thing was not updated at each new poll but only in case of change. If this is the case now, this is a bug (considering how much often it occurs) and I think I already notice myself that it was at least the case for groups.

I will check that and open an issue in Git.

Issue opened:

I already proposed a fix:

The fix is now merged.