This object is in archive! 

Suggestion for new Control Block: "Case"

Robert Hercz shared this idea 8 years ago
Under Consideration

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

Replies (6)

photo
1

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?

photo
1

oh you can scroll down on the main screen too, in chrome browser hold down middle mouse button.

photo
1

Adrian,

Just tested. you're right; the middle panel in the Rule Builder can scroll.

I am in the process of building a rule with 12 nested IF/ELSE; one for each event from a Wall Controller. It's ugly :-)

photo
photo
1

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).

photo
2

"SELECT CASE" would be useful to avoid nesting IF's, I agree, good idea.

photo
2

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...

photo
2

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 :-)

photo
1

Robert, your example is only for 3 devices, imagine 10. The rule would be long and the overview of what is what would be gone. Another way would be to have a lot of small (per device) rules but that clutters up the rules view. A nice CASE puzzle piece would clear that up.

If Zipato has good programmers, and I think they do, then a redesign is not necessary, only an enhancement ;-)

photo
1

It is very messy to write rules like that and they're hard to debug, "SELECT CASE" is a fairly common instruction in many programming language. If sensor/actuators grouping worked in zipabox or zipatile would be easier. But then again "SELECT CASE" would make it even simplier.

photo
photo
3

(I think those in favor of getting a CASE type block need to Vote for it)

Leave a Comment
 
Attach a file