I want to create a rule like this:
Can I do this in the Openhub gui also, or am I forced to use the VS plugin?
Thanks
/Franz
rule "iPhone Home"
when
Item iPhone_Location changed
then
// specify your home location
val PointType home_location = new PointType(new DecimalType(51.0), new DecimalType(4.0))
val PointType phone_location = iPhone_Location.state as PointType
val int distance = phone_location.distanceFrom(home_location).intValue()
// specify your preferred radius (in meters)
if ( distance < 200) {
iPhone_Home.postUpdate(ON)
logInfo("iPhone Home", "iPhone is at home.")
} else {
iPhone_Home.postUpdate(OFF)
logInfo("iPhone Home", "iPhone is away.")
}
end
If I understand correctly, you would like to add a rule using DSL (aka “the old openHAB2 way”?) instead of ECMAScript (aka “one of the rules-integrated scripting languages”)?
Do not copy-paste the whole of a “file” type DSL rule into a GUI entered rule’s script action.
The GUI takes care of all the when-then-end stuff and you only need the rule body.
That’s correct - but one step at a time I guess! if you copied all the “old” rule as a whole, you get the corresponding error-entries in the logs and can work from there!
Hi,
I managed to it thanks to all!
The only thing that did initially was not clear to me is that
“The Rule can embed a script”.
I thought I have to create a script and link it.