I am a newbee trying to use Openhab to control a Rachio-based watering system, At this time, I have successfully installed the Rachio binding and I am already able to perform some basic control of my sprinklers through Openhab.
One thing that I do not like in my current setup is that the watering duration needs to be specified in a number of seconds rather than a number of minutes. The fact is that the Rachio binding provides me with a runtime duration number in seconds that I can set at will before issuing a run command.
The setpoint Default_Zone_Runtime allows the user to specify a number of seconds (in increments of 300, i.e. 5 minutes). Then the user can start the sprinklers for that particular duration.
What I would like, is for the user to specify the runtime in minutes rather than seconds.The user would be able to specify a number of minutes and that number would then be converted to seconds before updating.Default_Zone_Runtime. Could you please help me identify one or more good ways of achieving that result?
I understand that for most of you this must be a trivial question, but I have not been able to figure out the answer using the available documentation and my very poor knowledge of java.
In the meantime, you could do this using a proxy Item.
You do not have to show every Item on the sitemap - so you can ‘hide’ the real duration Item behind the scenes.
You can create Items with no links to any real device or property, generally called proxy or virtual Items. Such Items can be shown and interactive in your UI, examined and manipulated by rules, just like any other Item.
So you can create a ‘minutes’ Item, put on your UI with a Setpoint. A rule can listen for commands to it (user clicks) and do maths on the command to convert minutes to seconds. Then the rule can command the real duration Item with seconds.
also i’m not a java nerd…i’m pretty shure there is a function to convert numbers, but no clue how this works. but in such a case, i often “workarround” with alias items and a rule like:
var ConvertMinSec = 0
rule “alias_item”
when
Item your_alias_item_in_sitemap changed
then
ConvertMinSec = ( your_alias_item_in_sitemap * 60)
Number Default_Zone_Runtime.postUpdate(ConvertMinSec)
}
end
Maybe it would be possible to multiplicate direct into the “postUpdate” brackets…?
So, you have to create a “alias” item in your item file, and then make this item visible instead the original one.
‘’’
var ConvertMinSec = 0
rule “Convertir minutes en secondes”
when
Item Zone_Runtime_Min changed
then
ConvertMinSec = (Zone_Runtime_Min * 60)
Number Default_Zone_Runtime.postUpdate(ConvertMinSec)
end
‘’’
But when the rule file is read, I get the following message:
‘’’
020-07-12 11:58:19.498 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘default.rules’, using it anyway:
This expression is not allowed in this context, since it doesn’t cause any side effects.
‘’’
And when I try to set the value of Zone_Runtime_Min, I get this other message:
‘’’
2020-07-12 12:17:54.184 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Convertir minutes en secondes’: Unknown variable or command ‘*’; line 26, column 22, length 21
‘’’
Line 26 happens to be the following one:
‘’’
ConvertMinSec = (Zone_Runtime_Min * 60)
‘’’
and column 22 is the point where ‘Zone_Runtime_Min’ begins.
‘’’
rule “Convertir minutes en secondes”
when
Item Zone_Runtime_Min changed
then
ConvertMinSec = Zone_Runtime_Min.state * 60
Number Default_Zone_Runtime.sendCommand(ConvertMinSec)
end
‘’’
Unfortunately, I am still receiving the very same error messages:
When the rule file is read:
‘’’
2020-07-12 12:51:11.430 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model ‘default.rules’, using it anyway:
This expression is not allowed in this context, since it doesn’t cause any side effects.
‘’’
And when I change the value of Zone_Runtime_Min:
‘’’
2020-07-12 12:52:46.853 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Convertir minutes en secondes’: Unknown variable or command ‘*’; line 26, column 21, length 27
‘’’
Rules are picky old things. It has to work out which operator we mean by something like ‘*’ based on the preceding variable. In this case, it’s an Item state, which doesn’t give the rules parser enough of a clue. We need to be more explicit -
ConvertMinSec = (Zone_Runtime_Min.state as Number) * 60
OK, my basic OH racho interface is working, but there is still something missing.
At this time, when I trigger my sprinklers through the Rachio app rather than through OH, then OH does not get notified that the relevant sprinklers are being triggered.
Is this what the “URL callback” and “port forwarding” stuff discussed in the Rachio binding documentation are about? In other words, if I do manage to set up the portforwarding stuff correctly, does this mean that OH and the Rachio app will become synchronized?