Suggestion for new Control Block: "Case"
We have IF and IF/ELSE, but could use something like ON CASE / CASE / CASE.
Example: I have a Wall Controller with 4 switches, each capable of sending events Pressed, Held and Released.
I could of course have 4 different Rules, one for each switch, where each rule cover the different events, but it would be much cleaner if I could have a WHEN <wall conroller> ANY, and inside this have a CASE where I could add tests for each state I need to test for.
I realize I could do this by having one IF for each test and I would not need a STOP inside each IF, but the way the rule designer is built, it expands spacially for the "end if" which would be unnecessary, making the RULE itself unreadable since rules become unreadable if they expand beyong a designer screen height...
So, in the interest of friendly programmability, I'd like to se a CASE type control block.
Brgds,
Robert Hercz
not sure exactly what you mean here, for your example you would use a when button any trigger, then 3 different ifs in the rule, if sensor block button pressed etc, another if block sensor when button held etc etc etc like I have attached. How do you mean?
not sure exactly what you mean here, for your example you would use a when button any trigger, then 3 different ifs in the rule, if sensor block button pressed etc, another if block sensor when button held etc etc etc like I have attached. How do you mean?
Adrian,
That is correct. As many IFs as I need, where the testing of the IFs in the list stops after the first TRUE, functionalitywise identical to the nested IF/ELSE statements in your sample "Using a Panic..." rule above, but "visually" and "structually" without the ELSEs and without the empty "end if" except for the last.
As described in my request, this is not programmically required as the same result can be created exactly as you describe. It would, however, make the rules simpler and visually easier to comprehend (and see on the screen).
Adrian,
That is correct. As many IFs as I need, where the testing of the IFs in the list stops after the first TRUE, functionalitywise identical to the nested IF/ELSE statements in your sample "Using a Panic..." rule above, but "visually" and "structually" without the ELSEs and without the empty "end if" except for the last.
As described in my request, this is not programmically required as the same result can be created exactly as you describe. It would, however, make the rules simpler and visually easier to comprehend (and see on the screen).
"SELECT CASE" would be useful to avoid nesting IF's, I agree, good idea.
"SELECT CASE" would be useful to avoid nesting IF's, I agree, good idea.
I to was thinking of this idea but in respect to a device "group" like WHEN "movement" ON CASE "movement" CASE Livingroom... CASE Kitchen... CASE Bedroom...
I to was thinking of this idea but in respect to a device "group" like WHEN "movement" ON CASE "movement" CASE Livingroom... CASE Kitchen... CASE Bedroom...
Frank,
For this to work, we'd need some other tests than device.. Today this would be done as
WHEN Livingroom:movement OR kitchen:movement OR bedroom:movement
IF livingroom:movement
do your things
ELSE
IF kitchen:movement
do your things
ELSE
IF bedroom:movement
do your thing
END IF
END IF
END IF
END WHEN
It could be done:
WHEN movement
CASE Livingrom
do something
CASE kichen
do something
CASE bedroom
do something
END CASE
END WHEN
-but that would involve a redesign of the event trigger/handler/device descriptor, and probably isn't likely to happen any time soon :-)
Frank,
For this to work, we'd need some other tests than device.. Today this would be done as
WHEN Livingroom:movement OR kitchen:movement OR bedroom:movement
IF livingroom:movement
do your things
ELSE
IF kitchen:movement
do your things
ELSE
IF bedroom:movement
do your thing
END IF
END IF
END IF
END WHEN
It could be done:
WHEN movement
CASE Livingrom
do something
CASE kichen
do something
CASE bedroom
do something
END CASE
END WHEN
-but that would involve a redesign of the event trigger/handler/device descriptor, and probably isn't likely to happen any time soon :-)
(I think those in favor of getting a CASE type block need to Vote for it)
(I think those in favor of getting a CASE type block need to Vote for it)
Replies have been locked on this page!