displayState should be ALWAYS set, making widget code less cumbersome

The displayState of an item should be ALWAYS set.

Currently it is not, so developing custom widgets can get quite annoying.

These seem to be the rules:

  1. No state description from me or binding → no displayState set
  2. State description pattern results in same output as state → no displayState set
  3. State description pattern results in different output than state → displayState is set

Rule 2 is the most cruel one IMHO and should be removed at least.
Ideally, displayState should be ALWAYS set, make it equal to state, if necessary.

The current situation leads to cumbersome code in custom widgets, for example:

        label: "=((items[props.setTemperatureItem].state == '4.5 °C') ? 'OFF' : (items[props.setTemperatureItem].displayState) ? items[props.setTemperatureItem].displayState.split(' ')[0] : items[props.setTemperatureItem].state.split(' ')[0]) + '/' + ((items[props.actualTemperatureItem].displayState) ? items[props.actualTemperatureItem].displayState.split(' ')[0] : items[props.actualTemperatureItem].state.split(' ')[0])"
1 Like

There is a trade-off here. The UI is collecting data from the core instance to get all the item states. Collecting more data (sending displayState information when it is unnecessary/redundant) is a measurable performance drain (and for mobile devices power drain).

I agree that at times it makes the widget code more cumbersome (occasionally to the point of absurdity), but that is a one-time or at least rare inconvenience for improved UI performance.

1 Like

You are right about the trade-off. However, it still is pretty cumbersome.