Single Channel with Multiple Items (links) or Multiple Channels - each one Item Link()

Hi Team

I would like a little advice on best practice

I have an HTTP Thing that retrieves a json result in a single json structure
it works (except for the aside i mention below but not really relevant).

I can create one channel and then link to each of the “variables” i need or I can create a channel for each variable and then one item (linked) for each channel (schematic representation below for reference)

which would be the preferred or recommended way

httpThing -

  • DataChannel
    • Item 1
    • item 2
    • item 3

or

httpThing -

  • DataChannel1
    • Item1
  • DataChannel2
    • Item2
  • DataChannel3
    • Item3

As an aside the reason I asked is that I needed to fetch more data from the json schema and adding the additional channels was not working as expected - i may try to debug this further

I can share the definitions if needed but was not sure if relevant
openHAB 4.3.5
Openhabian RPi5 8Gb

It depends on how you use the data from this service. The typical approach would be one Channel per data Item, but if this information is only ever used from a rule that can parse the JSON itself, it could be worthwhile to not have all of it separated into different Items.

Either approach is OK and which is better depends on how you use the information.

There are cases where you cannot easily parse out the data in the Channel. This usually happens when the JSON is a variable length array or the order of the elements in an array is not fixed. JSONPATH as implemented by OH cannot easily handle these sorts of cases so you need to use a rule to get at the data.

Hi Rich

Ok, understood, thanks and it makes no difference to the refresh of all channels of the thing since all channels are either refreshed by the request (http in this case) or they are not correct?

The reason i ask is because eon an HTTP thing definition there is this statement underneath refresh time

Time between two refreshes of all channels (s)

Correct. All the Channels of the Thing are refreshed from one pull of the HTTP endpoint. You won’t be hitting the server more often than necessary.

Thanks Rich