on rules only OR condition is allowed AND is no possible.
I need on contact ContactFullArmed switch all cameras 1234 ON or OFF.
// This is a situation of full armed object.
rule "AllCamON"
when
Item ContactFullArmed changed from CLOSED to OPEN
then
executeCommandLine … all cameras 1,2,3,4 ON
end
This is a situation of full disarmed object.
rule "AllCamOFF"
when
Item ContactFullArmed changed from OPEN to CLOSED
then
executeCommandLine … camera 1,2,3,4 OFF
end
How can I apply a rule with both Contact1 and Contact2 OPENed together (KNX binding vars) !
ContactFullArmed changed from CLOSED to OPEN together when second contact ContactPartiallyArmed
Third rule like:
// This is a situation of partially armed object.
rule "Cam12ON_Cam34OFF"
when
Item ContactPartiallyArmed changed from OPEN to CLOSED
then
executeCommandLine … camera 1,2 ON or camera 3,4 OFF
end
But this three rules doesn’t work correct, they are repeatly set with rules i a no correct way.
How can I apply such a rule with Contact1 and Contact2 are OPEN together!
Can I build in OH2 a math logical dummy variable as result from bool V1 AND V2 ?
P.S.
In a obviously SPS program I can use OR and AND conditions !
No matter if both signals are set in same second.
All situations are triggered with:
when V1 changes from CLOSE to OPEN
I have this three combinations:
state V1 is CLOSED and state V2 is CLOSED
Function: send four curl commands with switch ON all 1234 cameras
state V1 is OPEN and state V2 is OPEN
Function: send four curl command with switch OFF all 1234 cameras
state V1 is OPEN and state V2 is CLOSED
Function: send two curl command with switch OFF 1 and 2 cameras
and maybe two curl commands with switch ON cameras 3 and 4.
Item V1 changed or Item V2 changed
would trigger on in all changes regardsless of states.
I need different actions (curl exec cmds) for three situations.
My concrete example:
I have four IP cameras. All should be activated if only state V1 is active (OPEN)
If also AND state V2 is active (OPEN) cameras 1 2 should be switched OFF.
This means three rules and three different actions (curl cms).
Sorry for my bad english, I speek better german :0)
Im beginner in rules and script in OH2 59 years old :0(.
The point is to get a trigger for the rule to run, hence my suggestion!
Inside this rule you can check each possible situation and do the needed actions.
when
Item V1 changed or Item V2 changed
then
if(V1.state == OPEN)
{ if (V2.state == OPEN)
{
//do whatever is needed with V1 and V2 OPEN
} else {
//do whatever is needed with V1 OPEN and V2 CLOSED
}
} else {
if (V2.state == OPEN)
{
//do whatever is needed with V1 CLOSED and V2 OPEN
} else {
//do whatever is needed with V1 and V2 CLOSED
}
}
end
rule "V1andV2"
when
Item V1 changed or
Item V2 changed
then
if(V1.state == OPEN)
{
if(V2.state == OPEN)
{
do anything for V1 and V2 OPEN
}
else
{
do anything for V1 OPEN and V2 CLOSED
}
}
else
{
if(V2.state == CLOSED)
{
do anything for V1 CLOSED and V2 CLOSED
}
}
end