diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java index b7bf50cc8d2..5d5c1eecac3 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/openhab/core/io/rest/sitemap/internal/SitemapResource.java @@ -83,6 +83,7 @@ import org.openhab.core.model.sitemap.sitemap.Buttongrid; import org.openhab.core.model.sitemap.sitemap.Chart; import org.openhab.core.model.sitemap.sitemap.ColorArray; +import org.openhab.core.model.sitemap.sitemap.Colortemperaturepicker; import org.openhab.core.model.sitemap.sitemap.Condition; import org.openhab.core.model.sitemap.sitemap.Frame; import org.openhab.core.model.sitemap.sitemap.IconRule; @@ -145,6 +146,7 @@ * @author Laurent Garnier - New widget icon parameter based on conditional rules * @author Laurent Garnier - Added releaseCmd field for mappings used for switch element * @author Laurent Garnier - Added support for Buttongrid as container for Button elements + * @author Laurent Garnier - Added support for new sitemap element Colortemperaturepicker */ @Component(service = { RESTResource.class, EventSubscriber.class }) @JaxrsResource @@ -700,6 +702,10 @@ private PageDTO createPageBean(String sitemapName, @Nullable String title, @Null bean.maxValue = setpointWidget.getMaxValue(); bean.step = setpointWidget.getStep(); } + if (widget instanceof Colortemperaturepicker colortemperaturepickerWidget) { + bean.minValue = colortemperaturepickerWidget.getMinValue(); + bean.maxValue = colortemperaturepickerWidget.getMaxValue(); + } if (widget instanceof Buttongrid buttonGridWidget) { for (ButtonDefinition button : buttonGridWidget.getButtons()) { MappingDTO mappingBean = new MappingDTO(); diff --git a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext index eca85cbb3d6..f91d868378a 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/Sitemap.xtext @@ -15,7 +15,7 @@ Widget: (LinkableWidget | NonLinkableWidget); NonLinkableWidget: - Switch | Selection | Slider | Setpoint | Video | Chart | Webview | Colorpicker | Mapview | Input | Button | Default; + Switch | Selection | Slider | Setpoint | Video | Chart | Webview | Colorpicker | Colortemperaturepicker | Mapview | Input | Button | Default; LinkableWidget: (Text | Group | Image | Frame | Buttongrid) @@ -165,6 +165,17 @@ Colorpicker: ('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)*) ']')? & ('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)*) ']')?); +Colortemperaturepicker: + 'Colortemperaturepicker' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & + (('icon=' icon=Icon) | + ('icon=[' (IconRules+=IconRule (',' IconRules+=IconRule)*) ']') | + ('staticIcon=' staticIcon=Icon))? & + ('minValue=' minValue=Number)? & ('maxValue=' maxValue=Number)? & + ('labelcolor=[' (LabelColor+=ColorArray (',' LabelColor+=ColorArray)*) ']')? & + ('valuecolor=[' (ValueColor+=ColorArray (',' ValueColor+=ColorArray)*) ']')? & + ('iconcolor=[' (IconColor+=ColorArray (',' IconColor+=ColorArray)*) ']')? & + ('visibility=[' (Visibility+=VisibilityRule (',' Visibility+=VisibilityRule)*) ']')?); + Input: 'Input' (('item=' item=ItemRef) & ('label=' label=(ID | STRING))? & (('icon=' icon=Icon) | diff --git a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend index 307649aa2e0..791b360cf95 100644 --- a/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend +++ b/bundles/org.openhab.core.model.sitemap/src/org/openhab/core/model/sitemap/validation/SitemapValidator.xtend @@ -17,6 +17,7 @@ package org.openhab.core.model.sitemap.validation import org.openhab.core.model.sitemap.sitemap.Button import org.openhab.core.model.sitemap.sitemap.Buttongrid +import org.openhab.core.model.sitemap.sitemap.Colortemperaturepicker import org.openhab.core.model.sitemap.sitemap.Frame import org.openhab.core.model.sitemap.sitemap.LinkableWidget import org.openhab.core.model.sitemap.sitemap.Setpoint @@ -143,6 +144,14 @@ class SitemapValidator extends AbstractSitemapValidator { } } + @Check + def void checkColortemperaturepicker(Colortemperaturepicker ctp) { + if (ctp.minValue !== null && ctp.maxValue !== null && ctp.minValue > ctp.maxValue) { + error("Colortemperaturepicker on item '" + ctp.item + "' has larger minValue than maxValue", + SitemapPackage.Literals.COLORTEMPERATUREPICKER.getEStructuralFeature(SitemapPackage.COLORTEMPERATUREPICKER__MIN_VALUE)); + } + } + @Check def void checkInputHintParameter(Input i) { if (i.inputHint !== null && !ALLOWED_HINTS.contains(i.inputHint)) { diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java index 6cb30892ed0..9a5a77f8e92 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/components/UIComponentSitemapProvider.java @@ -48,6 +48,7 @@ import org.openhab.core.model.sitemap.sitemap.impl.ChartImpl; import org.openhab.core.model.sitemap.sitemap.impl.ColorArrayImpl; import org.openhab.core.model.sitemap.sitemap.impl.ColorpickerImpl; +import org.openhab.core.model.sitemap.sitemap.impl.ColortemperaturepickerImpl; import org.openhab.core.model.sitemap.sitemap.impl.ConditionImpl; import org.openhab.core.model.sitemap.sitemap.impl.DefaultImpl; import org.openhab.core.model.sitemap.sitemap.impl.FrameImpl; @@ -88,6 +89,7 @@ * @author Laurent Garnier - Added icon field for mappings * @author Mark Herwege - Make UI provided sitemaps compatible with enhanced syntax in conditions * @author Mark Herwege - Add support for Button element + * @author Laurent Garnier - Added support for new sitemap element Colortemperaturepicker */ @NonNullByDefault @Component(service = SitemapProvider.class) @@ -267,6 +269,15 @@ protected Sitemap buildSitemap(RootUIComponent rootComponent) { ColorpickerImpl colorpickerWidget = (ColorpickerImpl) SitemapFactory.eINSTANCE.createColorpicker(); widget = colorpickerWidget; break; + case "Colortemperaturepicker": + ColortemperaturepickerImpl colortemperaturepickerWidget = (ColortemperaturepickerImpl) SitemapFactory.eINSTANCE + .createColortemperaturepicker(); + widget = colortemperaturepickerWidget; + setWidgetPropertyFromComponentConfig(widget, component, "minValue", + SitemapPackage.COLORTEMPERATUREPICKER__MIN_VALUE); + setWidgetPropertyFromComponentConfig(widget, component, "maxValue", + SitemapPackage.COLORTEMPERATUREPICKER__MAX_VALUE); + break; case "Buttongrid": ButtongridImpl buttongridWidget = (ButtongridImpl) SitemapFactory.eINSTANCE.createButtongrid(); addWidgetButtons(buttongridWidget.getButtons(), component); diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java index f5eccaf2b4d..92994e1e269 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java @@ -112,6 +112,7 @@ * @author Laurent Garnier - Support added for multiple AND conditions in labelcolor/valuecolor/visibility * @author Laurent Garnier - new icon parameter based on conditional rules * @author Danny Baumann - widget label source support + * @author Laurent Garnier - Consider Colortemperaturepicker element as possible default widget */ @NonNullByDefault @Component(immediate = true, configurationPid = "org.openhab.sitemap", // @@ -302,6 +303,9 @@ private void applyConfig(@Nullable Map config) { } if (!isReadOnly && NumberItem.class.isAssignableFrom(itemType) && hasItemTag(itemName, "Setpoint")) { return SitemapFactory.eINSTANCE.createSetpoint(); + } else if (!isReadOnly && NumberItem.class.isAssignableFrom(itemType) + && hasItemTag(itemName, "ColorTemperature")) { + return SitemapFactory.eINSTANCE.createColortemperaturepicker(); } else { return SitemapFactory.eINSTANCE.createText(); }