This object is in archive! 

Add subroutines and constants

David Pritchard shared this idea 8 years ago
Under Consideration

A couple of suggestions:


1) It would be useful to be able to group a series of actions (and control conditions) together into a "subroutine" and invoke them from different rules. This is especially true because putting more than two "OR" conditions in a rule becomes unwieldly - it won't fit on the screen. So I find myself breaking the same big rule into separate smaller ones. And just, you know, in the name of code reuse!

2) Add constants - e.g. times, numbers. I often set the same value (say, the time I leave the house) in several rules. Changing it later is then a pain. Allow the constant to be used in the scheduler or in puzzles.

Replies (6)

photo
1

Nice suggestions!

photo
1

Very curious!


How do such rules as you described look like?


Is it possible for you to show some screenshots?


Best regards Jacob!

photo
1

Great idea.

photo
1

@Jacob: not sure what you're asking me. I can't provide screenshots of stuff that hasn't been implemented :-)


For subroutines, imagine a separate subroutine section on the right where you assemble puzzle pieces containing actions and conditions, for example: raise the blinds in the living room and the bedroom, and raise the awnings if lowered. You could assign a name to this, say "Open blinds & awnings". Then in the rule creator proper you would have a puzzle piece called "Run subroutine" (probably you'd have to find a more user-friendly name than "subroutine"). It would allow you to select the subroutine from the list of the ones you've created. You can then incorporate this into several rules, for example one which checks the weather when you leave in the morning and decides whether to lower or raise blinds, and another which reacts to changes in the weather during the day, lowering the blinds if the weather is cold and overcast, and raising them to take advantage of solar gain in winter. Just an example. Obviously, it's possible to have quite complex sequences of actions and conditions that you might want to reuse.

photo
1

Constants would be just like the variable puzzle pieces, except with fixed values. Ideally the scheduler would accept one of these pieces with a time value (which would mean redesigning it), or there'd be a new sensor piece that accepted it.

It's just to save the trouble of altering the same value in more than one place.

photo
1

A constant is a variable that never changes.

To create a constant, I have a rule that runs once a day (once a month would also work) that assigns values to a list of variables. No other rules overwrite these values, so they are effectively constants.

The attached example show the constant I created to define the volume of my Sonos player.

photo
1

I do exactly the same thing.

photo
Leave a Comment
 
Attach a file