-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be able to connect multiple conditions with AND in sitemap's valuecolor #3058
Comments
@lolodomo I would like to hear your opinion here. To me it looks very complex and a corner case. IMO it would be better to have |
I agree that the original proposal was too much complex. And in case we would add the AND operator, then why not adding other operatros like OR and NOT ? Too much complex and too much specific. Your idea @J-N-K could even be extended to provide the ability to use an item value as color in any labelcolor/valuecolor/iconcolor condition. This is not too much difficult, even if not trivial. I have a good knowledge where is the code to be changed in core framework. Any state change of the pointed item should trigger an update of the item using it as color value. This would require to consider the case the item is not of type String or its state is NULL or UNDEF. I would suggest to ignore the color condition in that case. How to distinguish a color value from an item containing the color value in the syntax ? A color is a string enclosed in quotes. An item would be an ID without quotes. This would require a change of sitemap syntax to add the ability to fill an ID (item name). WDYT ? @J-N-K : do you imagine real use cases for that ? Or is it something that will be used only by less than 5 users all over the world ? ;) |
I think a I think the sitemap change would be backward compatible in this case, so I don't see the risk of breaking something there. Regarding the use-case: I really don't know. I don't even use labelcolor or iconcolor, only valuecolor. I guess @rlkoshak would say: if it's there, someone will use it. But at least I would set my priority to other things. Depends a bit on how complex it is. |
NOT can be emulated for the whole expression by using operator != . valuecolor=[cond-A OR cond-B=="green"] is the same as valuecolor=[cond-A=="green", cond-B=="green"]. Both OR and NOT are available now, as far as no bracketed expressions are meant. Just AND is missing. Use case: I have a group with several items. I want to have the valuecolor of the group present the ON-OFF states of two items of the group. Then I see the on the main-sitemap-level just the group identifier and by the color I understand the values of that two items. Currently I have an extra item, which can store four values and based on the four values set the valuecolor of the group. |
@dilyanpalauzov : is our proposal OK for your use case ? You would still need an extra item and a rule that would set the expected color in that item. |
My current template is: valuecolor=[A=="green"="green", A=="red"="red" and so on]. So being able to specify just the item will simplify the chain. |
I have one more use case. When a pump works and moves water it consumes 700W. When there is no water to move, the pump turns off and consumes 0W. However sometimes the pump does not turn off, when it should, and then consumes between 400W and 440W, without moving any water (but air). So when the pump consumes between 400 and 440W I want to render the valuecolor as red, otherwise keep the default valuecolor. With AND syntax `valuecolor=[item>=400 AND item<=440="red"] would be very useful. |
For the last use-case I have now |
I will try to add the AND operator in color conditions. |
Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…rules Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr> Fix
…rules Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…ditional rules for icon Allow multiple conditions with AND operator in visibility/color/icon rules Closes openhab#3058 Also allow dynamic icon based on other item states. Allow dynamic icon even with non OH icon sources. Example: icon=[item1>0=temperature,==0=material:settings,f7:house] Related to openhab/openhab-webui#1938 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…ditional rules for icon Allow multiple conditions with AND operator in visibility/color/icon rules Closes openhab#3058 Also allow dynamic icon based on other item states. Allow dynamic icon even with non OH icon sources. Example: icon=[item1>0=temperature,==0=material:settings,f7:house] Related to openhab/openhab-webui#1938 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…ditional rules for icon Allow multiple conditions with AND operator in visibility/color/icon rules Closes openhab#3058 Also allow dynamic icon based on other item states. Allow dynamic icon even with non OH icon sources. Example: icon=[item1>0=temperature,==0=material:settings,f7:house] Related to openhab/openhab-webui#1938 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…ditional rules for icon Allow multiple conditions with AND operator in visibility/color/icon rules Closes openhab#3058 Also allow dynamic icon based on other item states. Allow dynamic icon even with non OH icon sources. Example: icon=[item1>0=temperature,==0=material:settings,f7:house] Related to openhab/openhab-webui#1938 Unit tests added or extended to cover the new features. Signed-off-by: Laurent Garnier <lg.hc@free.fr>
…ditional rules for icon Allow multiple conditions with AND operator in visibility/color/icon rules Closes openhab#3058 Also allow dynamic icon based on other item states. Allow dynamic icon even with non OH icon sources. Example: icon=[item1>0=temperature,==0=material:settings,f7:house] Related to openhab/openhab-webui#1938 Unit tests added or extended to cover the new features. Signed-off-by: Laurent Garnier <lg.hc@free.fr>
The usage of (multiple) AND conditions is now possible with the PR I proposed. No change in sitemap UIs is required. We just have to wait for the review and merge. |
Concerns labelcolor, valuecolor and visibility Also fix wrong positions of ")" in Sitemap.xtext Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Concerns labelcolor, valuecolor and visibility Also fix wrong positions of ")" in Sitemap.xtext Closes openhab#3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Concerns labelcolor, valuecolor and visibility Also fix wrong positions of ")" in Sitemap.xtext Closes #3058 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Currenlty Sitemaps’s can have dynamic
valuecolor=[…]
. In the brackets conditions can be written, followed by colour. When a condition is met, the following colour is used and the remaining conditions are not evaluated.I want to be able conjunct two conditions, as in
valuecolor=[A==ON AND B==ON ⇒ "green" A==ON AND B==OFF ⇒ "RED" A==OFF AND B==ON ⇒ "blue" A==OFF AND B==OFF ⇒ "white"]
, or the equivalent but shortervaluecolor=[A==ON AND B==ON ⇒ "green" A==ON="red" A==OFF AND B==ON ⇒ "blue" A==OFF="white"]
.Rationale:
I have a Group with item=. By using the value of the item I want to encode the state of two different items in the group, so that I can conclude that states without having to open the Group by clicking on it.
The text was updated successfully, but these errors were encountered: