Comments (27)
@kaikreuzer : please move this RFC in openhab-core repo and please add the "sitemap" tag.
from openhab-core.
labelcolor
, iconcolor
, visibility
parameters can only be applied to a sitemap element. It is handled at sitemap element level in core framework.
To achieve your request, we should create a new sitemap element Button
as a sub element of a Buttongrid
. The current buttons
parameter of Buttongrid
will then be replaced by a list of Button
inside Buttongrid
. Then each Button
element, like any other sitemap element could have parameters labelcolor
, iconcolor
, visibility
.
The syntax would be something like that:
Buttongrid [label="xxx"] {
Button line=X column=Y item=xxx command=xxx label="xxx" [icon=xxx] [labelcolor=[xxx]] [iconcolor=[xxx]] [visibility=[xxx]]
Button line=X column=Y item=xxx command=xxx label="xxx" [icon=xxx] [labelcolor=[xxx]] [iconcolor=[xxx]] [visibility=[xxx]]
Button line=X column=Y item=xxx command=xxx label="xxx" [icon=xxx] [labelcolor=[xxx]] [iconcolor=[xxx]] [visibility=[xxx]]
}
It even makes the syntax easier for the user.
It has also the advantage that each button can be linked to a different item.
Today, I believe we should have gone in that direction at the beginning.
We could keep backward compatibility by making the buttons
and item
parameters optional on the Buttongrid
element. If no Button
are declared as child of Buttongrid
but buttons
and item
parameters are set, we can consider the current behaviour.
It is relatively easy to enhance in the core framework (sitemap syntax), I can do it. The biggest changes have to be implemented in each sitemap UI. I could do it for Basic UI. @openhab/android-maintainers : are you interested to implement this enhancement in the Android app ?
@openhab/ios-maintainers for information (if I am not wrong, Buttongrid is not yet implemented in the iOS app).
from openhab-core.
The suggested syntax is much more readable than the current one π
Adapting the Android app should be doable.
from openhab-core.
@mueller-ma : it is probably too late for 4.2 regarding all the changes to do ? I am not sure if we break the sitemap REST API or if we keep the current API response structure when buttons
parameter is used and have a new one when buttons are sub-elements of the Buttongrid
? I imagine it will be better to have a (new) unique structure of response not depending on whether the buttons were declared in the buttons
parameter or as sub-elements. But then this will become a breaking change for the Android app. WDYT ?
from openhab-core.
Yes, maybe it's the best to update the API when using the new syntax.
from openhab-core.
This will lead to something even more powerful than today, with buttons in the grid that can be linked to different items, with buttons that can be stateless or stateful, and with conditional icon / color / visibility.
from openhab-core.
In the core PR I just proposed, I increased the version of REST API so that you can know if new structure is supported by the server. Sitemap REST API response still contains a list of MappingDTO
in field mappings
if the old buttons
parameter is used.
It includes a list of WidgetDTO
in field widgets
in case the grid contains Button elements.
It makes the change backward compatible with existing UIs.
from openhab-core.
It is almost implemented in Basic UI. Dynamic colors for label and icon is working. Stateful / stateless is done. Press & release is done. Dynamic icon should work but still need to be tested. I even accept a combination of old and new ways to provide buttons for the same Buttongrid. Remains the visibility to implement.
Regarding core framework, I need to change something in the REST/SSE API regarding returned label and icon for the Button element. They should not be inherited from the item like the other sitemap elements. If no label is provided, the label of the button should be its "command". If no icon is provided, we should consider a button with text and no icon.
from openhab-core.
The proposed syntax for the Button
is :
Button item=<item> [label=<label>] [icon=<icon>] row=<row> column=<column> [stateless] click=<cmd> [release=<cmd>] [labelcolor=[...]] [iconcolor=[...]] [visibility=[...]]
Button item=<item> [label=<label>] [staticIcon=<icon>] row=<row> column=<column> [stateless] click=<cmd> [release=<cmd>] [labelcolor=[...]] [iconcolor=[...]] [visibility=[...]]
Button item=<item> [label=<label>] [icon=[...]] row=<row> column=<column> [stateless] click=<cmd> [release=<cmd>] [labelcolor=[...]] [iconcolor=[...]] [visibility=[...]]
Explanations of the parameters:
- The position of the button in the grid is defined by the
row
andcolumn
parameters. - The
label
parameter defines the text to display in the button. If not present, the value of the command (click
parameter) is used as text. - The
icon
parameter defines the icon to display in the button. If not present, the button will contain a text. The icon can be dynamic by defining rules in theicon
parameter. - By default, a button is stateful. It is stateless if
stateless
parameter is present. - A button is a click button by default, the command to send to the item is defined by the
click
parameter. Press & release behaviour is possible by setting theclick
andrelease
parameters. - Label and icon color can be dynamic using the
labelcolor
andiconcolor
parameters. - Visibility of the button can be dynamic using the
visibility
parameter.
Such Button
element is valid only inside a Buttongrid
element.
from openhab-core.
Fully implemented in Basic UI now.
The only current limit is that Basic UI only supports one button at a certain position in the grid. So you can now use the visibility parameter to show or hide a button in the grid but you can't define several buttons at the same position with different visibility conditions in order to switch between buttons at a certain position in the grid. I could try to enhance that later but with the constraint that there will be always only one visible button at a position in the grid.
from openhab-core.
Adapting the Android app should be doable.
@mueller-ma : it is now merged, so you can work on it for Android when you like.
I will update sitemap documentation.
from openhab-core.
@lolodomo Do I get this right that the UI sitemap builder needs to be changed as well to support this additional functonality?
from openhab-core.
Yes @mherwege , correct.
from openhab-core.
And the old version of the API still works as well? I donβt think that is appropriate for UI configuration, leaving that choice. I need to think about how to cope with this. It lay be to just always provide the new format from UI configuration.
from openhab-core.
And the old version of the API still works as well?
Yes, both syntaxes are accepted.
You can even combine both.
from openhab-core.
The only current limit is that Basic UI only supports one button at a certain position in the grid. So you can now use the visibility parameter to show or hide a button in the grid but you can't define several buttons at the same position with different visibility conditions in order to switch between buttons at a certain position in the grid. I could try to enhance that later but with the constraint that there will be always only one visible button at a position in the grid.
Finally implemented: openhab/openhab-webui#2580
from openhab-core.
I discovered an issue in the sitemap validation code I added, when the Buttongrid + Button are in a sub-page. It leads to this error when the sitemap is loaded and validated:
Linkable widget should not contain Button, Button is allowed only in Buttongrid
and the Buttongrid is then not rendered in Basic UI.
Of course the error is wrong as all my Button elements are in a Buttongrid element.
I will investigate.
The old style Buttongrid is still correctly supported in a sub-page.
from openhab-core.
@lolodomo a few questions:
- Is the old style buttongrid without sub-widgets going to continue to be supported, or will it be deprecated?
- Is there a plan to make the
Button
widget to "default" to the item specified in its parentButtongrid
when one is not specified? In a way this would reduce the flexibility but at the same time also saves typing / duplication when we still want to control the same item but with the added flexibility of using theButton
widgets (e.g. custom coloring)
from openhab-core.
I discovered an issue in the sitemap validation code I added, when the Buttongrid + Button are in a sub-page. It leads to this error when the sitemap is loaded and validated:
Linkable widget should not contain Button, Button is allowed only in Buttongrid
and the Buttongrid is then not rendered in Basic UI.
I noticed this when the Buttongrid
isn't assigned an item like this:
sitemap test {
Frame {
Buttongrid {
Button item=TestSwitch1 row=1 column=1 click="ON" label="ON" visibility=[TestSwitch1!=ON]
Button item=TestSwitch1 row=1 column=1 click="OFF" label="OFF" visibility=[TestSwitch1==ON]
}
}
}
But when I assigned an item to Buttongrid, it worked fine. In both cases, they're nested inside a Frame.
sitemap test {
Frame {
Buttongrid item=TestSwitch1 {
Button item=TestSwitch1 row=1 column=1 click="ON" label="ON" visibility=[TestSwitch1!=ON]
Button item=TestSwitch1 row=1 column=1 click="OFF" label="OFF" visibility=[TestSwitch1==ON]
}
}
}
from openhab-core.
Yes, I noticed the same. Strange that it depends on presence of item parameter...
from openhab-core.
In fact, the problem is when there is no parameter set for the Buttongrid element. Adding any parameter (item or label or labelcolor or iconcolor ...) solves the issue. It does not depend if the Buttongrid element is on the main page or a sub-page.
I did not notice the problem because my Buttongrid elements have at least one parameter when testing (even if some have no item parameter).
from openhab-core.
@lolodomo a few questions:
1. Is the old style buttongrid without sub-widgets going to continue to be supported, or will it be deprecated?
To be decided but Basic UI currently supports the old style, the new style and even a combination of both.
2. Is there a plan to make the `Button` widget to "default" to the item specified in its parent`Buttongrid` when one is not specified? In a way this would reduce the flexibility but at the same time also saves typing / duplication when we still want to control the same item but with the added flexibility of using the `Button` widgets (e.g. custom coloring)
I hesitated when implementing. I don't remember exactly but I probably give up because it could lead to have no item neither on Button nor on Buttongrid. But thinking of it, in this case, the UI could simply log a message and do nothing when clicking a button.
I am ok to change that.
from openhab-core.
In fact, the problem is when there is no parameter set for the Buttongrid element. Adding any parameter (item or label or labelcolor or iconcolor ...) solves the issue. It does not depend if the Buttongrid element is on the main page or a sub-page.
I did not notice the problem because my Buttongrid elements have at least one parameter when testing (even if some have no item parameter).
Bug is fixed by #4240
from openhab-core.
2. Is there a plan to make the `Button` widget to "default" to the item specified in its parent`Buttongrid` when one is not specified? In a way this would reduce the flexibility but at the same time also saves typing / duplication when we still want to control the same item but with the added flexibility of using the `Button` widgets (e.g. custom coloring)
I hesitated when implementing. I don't remember exactly but I probably give up because it could lead to have no item neither on Button nor on Buttongrid. But thinking of it, in this case, the UI could simply log a message and do nothing when clicking a button.
I am ok to change that.
See #4241
from openhab-core.
2. Is there a plan to make the `Button` widget to "default" to the item specified in its parent`Buttongrid` when one is not specified? In a way this would reduce the flexibility but at the same time also saves typing / duplication when we still want to control the same item but with the added flexibility of using the `Button` widgets (e.g. custom coloring)
I hesitated when implementing. I don't remember exactly but I probably give up because it could lead to have no item neither on Button nor on Buttongrid. But thinking of it, in this case, the UI could simply log a message and do nothing when clicking a button.
I am ok to change that.See #4241
Thanks! It sounds like you were planning to implement the inference logic on client side, which means the logic also needs to be implemented on android / ios too. Wouldn't it be easier to just make the Button widget to set its item parameter to its parent's at creation time when one is not provided? Is it because the code is generated by xtext?
from openhab-core.
Wouldn't it be easier to just make the Button widget to set its item parameter to its parent's at creation time when one is not provided? Is it because the code is generated by xtext?
Although it's not quite "pure" in logic, we can sneak that code into here:
from openhab-core.
@jimtng : I give up the idea because I don't want to "patch" the model (I don't think we already did that in the past) and we absolutely need the item set at each Button level to have all the stuff working. Everything is based on attachment of a widget to an item. It is what triggers the update of a widget in particular.
from openhab-core.
Related Issues (20)
- Allow offset for "at the time specified in an item's state" trigger HOT 7
- customTags.yaml not loading after reboot HOT 6
- Thing File based configuration not loaded correctly after changing HOT 33
- Attempting to send a state update of an item which doesn't exist: __v_isRef HOT 7
- Default statedescription pattern for NumberItem HOT 4
- Error during logger activation HOT 4
- Snapshot 4069: failed to install bundles at startup HOT 39
- Missmatch between system:start-level and openhab.event.StartlevelEvent HOT 5
- OpenHAB 4.1.2 - Karaf cannot start HOT 4
- Add SDDP service to core HOT 4
- Sitemap widget grid
- [ephemeris] Calls to `isBankHoliday` failing with exception HOT 6
- Local build failing in config.core due to violation in schema\config-description-1.0.0.xsd HOT 2
- Thing file loading issue HOT 12
- Persisted group items with base type Number:Dimension not restored correctly in persistence extensions HOT 3
- What to do with my 'fake' device code
- Possible Startup loop HOT 2
- Skipping setup causes issues due to locale not being set HOT 2
- [Feature] Add support to format channel-type description using `html` tags HOT 1
- oh-rollershutter-item with stateInCenter set doesn't respect State Description Pattern HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openhab-core.