Jump to content

Feature request - Functions


eagleco

Recommended Posts

Posted

I'd love it if we could create functions that accept devices/variables passed as parameters for use in generic logic.  This would allow complex/smart functionality to be easily re-used in multiple places and allow changes to the function(s) to affect them all.

 

I've run across several forum topics discussing complicated control schemes using 5 or 6 programs, and I believe functions would make these much easier to implement/maintain.

 

I'm envisioning this as creating a prototype folder which allows the parameters to be set, and then the programs within the folder use pointer references from the folder definition.  Then the user can just create instances of that folder to use the same functionality for different devices/rooms.

 

i.e.

FunctionFolder FancyLightControl (light = BathLight; motion = BathMotion; door = BathDoor; $opendelay=1; $closeddelay=10)

 

Let me know if that's not clear.

Posted

Parameter passing relies on linear program style coding and ISY is a trigger based real-time language so it probably will never happen. This is a hard concept for classic programmers to swallow for the first 90 days until the warranty wears off :)

 

However, using the state variables one single line of code can pass a parameter and call a subroutine.

 

To accomplish this you just need to define a state variable and write an enabled program to test it.

 

If

$Statevar > -999999

Then

Do whatever with $statevar

Else

 

Now anytime you change the value of $statevar the subroutine is called and the parameter is assigned into the variable for use in the subroutine. Multiple variables take a little more lines of code. Not fancy and compact but it works and utilises the speed of ISYs engine to do some of the work.

 

 

One caveat is that to pass the same as previous value you need to temporarily set the state var to an unused value and back. I use -1 for values that are always positive.

Posted

Yeah it has been an adjustment getting used to programming in ISY but I look at it as a fun new challenge.

 

I think I get your point about triggering with state variables, but that still doesn't let me re-use the same logic for different groups of devices.

 

My idea still seems possible (in my mind at least  :wink: ) because the prototype folder is sort of just a GUI trick.  Behind the scenes, each instance is still implemented as a normal set of event driven programs with the devices/variables substituted.  Maybe calling it a "function" isn't the right terminology...  The big benefit would be having all instances linked back and updated accordingly whenever the prototype is changed.

 

 

Unrelated question but you seem to be very knowledgeable on all things ISY... What's the current state of version 5?  Would you recommend upgrading yet for someone (me) that only has one controller?  I don't have anything terribly important on it, but don't want to frustrate the wife unnecessarily with things not working.  On the other hand I'm anxious to play with new features :)

Posted

Yeah it has been an adjustment getting used to programming in ISY but I look at it as a fun new challenge.

 

I think I get your point about triggering with state variables, but that still doesn't let me re-use the same logic for different groups of devices.

 

My idea still seems possible (in my mind at least  :wink: ) because the prototype folder is sort of just a GUI trick.  Behind the scenes, each instance is still implemented as a normal set of event driven programs with the devices/variables substituted.  Maybe calling it a "function" isn't the right terminology...  The big benefit would be having all instances linked back and updated accordingly whenever the prototype is changed.

 

 

Unrelated question but you seem to be very knowledgeable on all things ISY... What's the current state of version 5?  Would you recommend upgrading yet for someone (me) that only has one controller?  I don't have anything terribly important on it, but don't want to frustrate the wife unnecessarily with things not working.  On the other hand I'm anxious to play with new features :)

Knowledgeable? Well thanks but I only consider myself in the middle of the pack, so far. I did do some pretty serious real time event based programming for grid control systems and really liked it, after it was done. My career was probably on the line.  Visual basic is event trigger based and did that for 20 years as a hobby mostly.

 

v5.0.2 Beta still has a few bugs that would annoy a newbie somewhat but mostly GUI stuff. I would recommend the next release as the "more aesthetic" bugs get fixed. UDI puts out very good stuff, even in Beta, but v5.0.1 seemed like they started over with much of the GUI stuff.

 

Go for the last v4.3.20 version. It has most of the variable features that v5 has, and mostly GUI cleaner, as is. Hopefully v5.0.3 will drop soon and that would be the one I would jump for, based on your situation. Probably only really polished users will ever find any bugs in that version, based on my past experiences. I have installed almost every version since v3 and ISY has never lit my gas stove, opened my windows in the winter,  or turned on my mattress vibrator when I wasn't home. :)

 

ISY upgrading is so easy compared to many systems.

 

Many want elseif or case structures. That could use parameters fan out subroutine calls to multiple actions with one program.

 

If    5:00am then run program (If)  'early morning'

 

ElseIf 6:00 am run then program (if)  'morning'

 

ElseIf 7:00 am then run program (If) 'late morning'

 

Else

   ---

 

:)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...