Hello,
Seeking to understand more how can you create an array with “key” and “value”? I would like to create an array with a key and as value the state of an “item”, so I could display the states in a list with their descriptive key.
to do this must we create an array or a “Hashmap”?
Or is a group the right tool?
I have never done a table in openhab and would like to start to be able to create and interact with them, on javadoc I must say not to manage to transpose what I see on openhab, do you have a simple example to help me understand the table creation base under openhab?
like every time you help me Thank you in advance
Maybe it is a good start to describe what you like to achive in more detail.
If you like key / value pair the Hashmap does the trick, but i don’t understand why you would like to display the map. It is not possible to display the map directly in openHAB.
Give us some more information.
in fact for example I have a variable of type boolean, which has as test value “6” items with conditions which must all be “true” for my variable to be “true”, if one of the variables is not not the execution of the rule will not happen. I would like to be able to display which item with the condition “false” is responsible, for example by putting an Item of type String which displays the item (s) with the status “false”, one can as a member group but in the form of an array or a list , I hope to explain myself well here is the rule that I would like to transform to display a String item with the list of items and their value:
rule "store banne down when time is hot , wind is low and rain is low"
when
Time cron "0 00 12 * * ? *" //A 12h00:00 du
or
Time cron "0 30 12 * * ? *" //A 12h30:00 du
or
Time cron "0 00 13 * * ? *" //A 13h00:00 du
or
Time cron "0 30 13 * * ? *" //A 13h30:00 du
or
Time cron "0 00 14 * * ? *" //A 14h00:00 du
or
Time cron "0 30 14 * * ? *" //A 14h30:00 du
or
Time cron "0 00 15 * * ? *" //A 15h00:00 du
or
Time cron "0 30 15 * * ? *" //A 15h30:00 du
or
Time cron "0 00 16 * * ? *" //A 16h00:00 du
or
Time cron "0 30 16 * * ? *" //A 16h30:00 du
or
Time cron "0 00 17 * * ? *" //A 17h00:00 du
or
Time cron "0 30 17 * * ? *" //A 17h30:00 du
or
Time cron "0 00 18 * * ? *" //A 18h00:00 du
or
Time cron "0 30 18 * * ? *" //A 18h30:00 du
or
Time cron "0 00 19 * * ? *" //A 19h00:00
or
Time cron "0 31 19 * * ? *" //A 19h30:00
or
Time cron "0 00 20 * * ? *" //A 20h00:00 i
or
Time cron "0 30 20 * * ? *" //A 20h30:00
then
if(Mode_VoletProtectionSoleil_PeriodOfyear.state == ON && Mode_VoletProtectionSoleil_ConditionClima.state == ON && InfoCrepusculaireErePositionElevation.state > 11 | "°" && InfoCrepusculaireErePositionAzimuth.state > 175 | "°" && InfoCrepusculaireErePositionAzimuth.state < 290 | "°")
{
if(ShutterBanne.state != 100) { ShutterBanne.sendCommand(100)}
logInfo("ShutterBanne","ShutterBanne toutes le conditions sont remplie")
}
else
{
if(ShutterBanne.state != 0){ ShutterBanne.sendCommand(0)}
logInfo("ShutterBanne","ShutterBanne les conditions ne sont pas remplies")
}
end
if the first condition is not true, I would like through a String item to see which condition is not fulfilled, or even their being at all, isn’t there a solution other than a group ? a list? Thanks for your help ! unfortunately I don’t understand how to create a list with rule DSL
maybe like this : array= [key1,item1; key2,item2; key3,item3; …] ps: i know this syntax don’t exist
then in a item String type xxxxxx.postupdate(array) to show all result or whith filter only the “false” one
To be honest i still do not understand why you want to see which condition does match / not match.
1.) First i would try to reduce the cron trigger
2.) Independant from how to display the different states you have to break up the condition into different parts.
period_of_year = Mode_VoletProtectionSoleil_PeriodOfyear.state == ON
protection_mode = Mode_VoletProtectionSoleil_ConditionClima.state == ON
....
final_condition = period_of-year && protection_mode && ...
3.) How to display things. If your intention is more logging and debugging a logstatement is maybe the solution. Fpr each condition you could set a log statement. Hope this is right, because i am using HABApp with python for my rules
period_of_year = Mode_VoletProtectionSoleil_PeriodOfyear.state == ON
log.info("myRules", "Condition is ...") // Please check the log statement in Documentation
To put the values into a map give you only the opportunity to process things in a loop and maybe use map / reduce. The result could go into one or more log statements or into a string item. But be aware that displaying the all condition is not so easy, becaus the ui are limited with that.
Another option is only to log / display only the false conditions. This cloud be done in a Loop as well.
var buildString = "False stuff: "
if (some condition != true( {
// do other stuff
buildString = buildString + " report some condition; "
}
if (other condition != true( {
// do other stuff
buildString = buildString + " report some other condition; "
}
if ( ....
}
someStringItem.postUpdate(buildString)
yes , i like that thanks and i test this quickly , having a list is not a good idea ? maybe is not a good choice ?
It all depends what you are trying to do. There are no ‘List’ type Items. Everything you want in a UI has to go through an Item. So there’s no direct way to put a List in the UI, if that’s what you are trying to do.
yes is that…and is not possible or with a string item type , your first idea what fine and do the job , i try it , thanks for your time for helping me
You could replace all your cron statements with this one which should do the same thing:
0 0/30 12-20 * * ? *
Every 30 minutes, between 12:00 and 20:59
whaow !!! clean way ! amazing, i learn every day with you ! thanks again !
Here is what I did with your help for “the String item”:
rule "Test des valeurs mode volets"
when
Time cron "0 0/5 * 1/1 * ? *"//Test toutes 5 minutes
or
System started
then
var StatusCondition = ""
if(MeteoTemp_Max0.state <= 22){ StatusCondition = StatusCondition +"Température max trop base:" + MeteoTemp_Max0.state +"°, "}
else if(Wind_Speed.state >= 40){ StatusCondition = StatusCondition +"Vent trop ford:" + Wind_Speed.state +"kmh, "}
else if(Rain.state >= 2){ StatusCondition = StatusCondition +"Pluie annoncée:" + Rain.state +"mml, "}
else if(Clouds.state >= 70){ StatusCondition = StatusCondition +"Trop de nuages:" + Clouds.state +"%, "}
else if(vTimeOfDay.state != "DAY"){ StatusCondition = StatusCondition +"Ce n'est pas la journée:" + vTimeOfDay.state +", "}
else (StatusCondition = "les Conditions sont bonnes")
ConditionMeteoForVolet.postUpdate(StatusCondition)
logInfo("test","string=" + StatusCondition)
end
And here what it gives on the UI (In 2.5) I have not yet gone to 3 on my production version.
thanks all !
Better than running the rule every 5 minutes would be to trigger when any of the items you check change. Not that it should impact performance in a noticeable way, but imo it’s better to reduce unnecessary rule runs, plus the status of the target item updates directly when the conditions change.