Skip to content

Commit

Permalink
Set a default presentation pattern for String/Number/Datetime unmanag…
Browse files Browse the repository at this point in the history
…ed items

Related to openhab#4071 and openhab#3835

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Apr 7, 2024
1 parent cbb458e commit 87f947d
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -38,6 +38,7 @@
import org.openhab.core.items.ItemUtil;
import org.openhab.core.items.dto.GroupFunctionDTO;
import org.openhab.core.items.dto.ItemDTOMapper;
import org.openhab.core.library.CoreItemFactory;
import org.openhab.core.model.core.EventType;
import org.openhab.core.model.core.ModelRepository;
import org.openhab.core.model.core.ModelRepositoryChangeListener;
Expand Down Expand Up @@ -255,6 +256,13 @@ private void processBindingConfigsFromModel(String modelName, EventType type) {
label = label.substring(0, label.indexOf("[")).trim();
stateDescriptionFragments.put(modelItem.getName(),
StateDescriptionFragmentBuilder.create().withPattern(format).build());
} else if (CoreItemFactory.STRING.equals(item.getType())
|| CoreItemFactory.DATETIME.equals(item.getType())) {
stateDescriptionFragments.put(modelItem.getName(),
StateDescriptionFragmentBuilder.create().withPattern("%s").build());
} else if (CoreItemFactory.NUMBER.equals(item.getType())) {
stateDescriptionFragments.put(modelItem.getName(),
StateDescriptionFragmentBuilder.create().withPattern("%.0f").build());
} else {
stateDescriptionFragments.remove(modelItem.getName());
}
Expand Down

0 comments on commit 87f947d

Please sign in to comment.