mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-27 12:41:32 +01:00
Extend sitemap syntax for switch to support press & release buttons (#4183)
* Extend sitemap syntax for switch to support press & release buttons Mappings attribute for switch element now accepts one or two commands for each button. If only one command is provided, the button is a click button, the command is sent to the item when the button is clicked. If two commands are provided (separated by ":"), the button is a press & release button, the first command is sent to the item when the button is pressed and the second when the button is released. Syntax example for a click button: Switch item=DemoSwitch mappings=[ ON="ON" ] Syntax example for a press & release button: Switch item=DemoSwitch mappings=[ ON:OFF="ON" ] Related to #3822 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
6aed435c77
commit
b40e6db514
@ -18,12 +18,14 @@ package org.openhab.core.io.rest.sitemap.internal;
|
|||||||
* @author Kai Kreuzer - Initial contribution
|
* @author Kai Kreuzer - Initial contribution
|
||||||
* @author Laurent Garnier - New fields position and icon
|
* @author Laurent Garnier - New fields position and icon
|
||||||
* @author Laurent Garnier - Replace field position by fields row and column
|
* @author Laurent Garnier - Replace field position by fields row and column
|
||||||
|
* @author Laurent Garnier - New field releaseCommand
|
||||||
*/
|
*/
|
||||||
public class MappingDTO {
|
public class MappingDTO {
|
||||||
|
|
||||||
public Integer row;
|
public Integer row;
|
||||||
public Integer column;
|
public Integer column;
|
||||||
public String command;
|
public String command;
|
||||||
|
public String releaseCommand;
|
||||||
public String label;
|
public String label;
|
||||||
public String icon;
|
public String icon;
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
* @author Laurent Garnier - Added icon field for mappings used for switch element
|
* @author Laurent Garnier - Added icon field for mappings used for switch element
|
||||||
* @author Laurent Garnier - Support added for multiple AND conditions in labelcolor/valuecolor/visibility
|
* @author Laurent Garnier - Support added for multiple AND conditions in labelcolor/valuecolor/visibility
|
||||||
* @author Laurent Garnier - New widget icon parameter based on conditional rules
|
* @author Laurent Garnier - New widget icon parameter based on conditional rules
|
||||||
|
* @author Laurent Garnier - Added releaseCmd field for mappings used for switch element
|
||||||
*/
|
*/
|
||||||
@Component(service = { RESTResource.class, EventSubscriber.class })
|
@Component(service = { RESTResource.class, EventSubscriber.class })
|
||||||
@JaxrsResource
|
@JaxrsResource
|
||||||
@ -635,6 +636,7 @@ public class SitemapResource
|
|||||||
for (Mapping mapping : switchWidget.getMappings()) {
|
for (Mapping mapping : switchWidget.getMappings()) {
|
||||||
MappingDTO mappingBean = new MappingDTO();
|
MappingDTO mappingBean = new MappingDTO();
|
||||||
mappingBean.command = mapping.getCmd();
|
mappingBean.command = mapping.getCmd();
|
||||||
|
mappingBean.releaseCommand = mapping.getReleaseCmd();
|
||||||
mappingBean.label = mapping.getLabel();
|
mappingBean.label = mapping.getLabel();
|
||||||
mappingBean.icon = mapping.getIcon();
|
mappingBean.icon = mapping.getIcon();
|
||||||
bean.mappings.add(mappingBean);
|
bean.mappings.add(mappingBean);
|
||||||
|
@ -204,7 +204,7 @@ Button:
|
|||||||
row=INT ':' column=INT ':' cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?;
|
row=INT ':' column=INT ':' cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?;
|
||||||
|
|
||||||
Mapping:
|
Mapping:
|
||||||
cmd=Command '=' label=(ID | STRING) ('=' icon=Icon)?;
|
cmd=Command (':' releaseCmd=Command)? '=' label=(ID | STRING) ('=' icon=Icon)?;
|
||||||
|
|
||||||
VisibilityRule:
|
VisibilityRule:
|
||||||
conditions+=Condition ('AND' conditions+=Condition)*;
|
conditions+=Condition ('AND' conditions+=Condition)*;
|
||||||
|
Loading…
Reference in New Issue
Block a user