Jump to content

Can I write a program and re-apply it to mulitple devices?


Derek Atkins

Recommended Posts

I'm an old-school programmer and truly believe in parameterization and the "write once, use many" mode of writing programs. I have a dozen sensors in my Insteon network that I'd like to monitor, and specifically I'd like to monitor them the same way. Basically, I'd like to write a program that says:

IF

THEN

ELSE


But I'd like to write this program ONCE and then be able to apply it to each of the dozen sensors. If I add a new sensor, I'd like to be able to say:
Apply program "Low Battery" to

So far the only way I've found to do this is literally copy an existing program and change the clauses in there to reference the new sensor. In old-school this is called "copy and paste". The problem with this approach is that if I find a bug in the program, or I want to slightly change how the program works, I need to do that in multiple places instead of fixing it once have having all instances reference the new program.

In THIS case, the programs are not very complicated, so copy-and-paste is not too much of a burden, but as I get to more complicated schemes I'd like to know if I can do the "right programming thing"?

Thanks!

Link to comment
16 minutes ago, Derek Atkins said:

I'm an old-school programmer and truly believe in parameterization and the "write once, use many" mode of writing programs. I have a dozen sensors in my Insteon network that I'd like to monitor, and specifically I'd like to monitor them the same way. Basically, I'd like to write a program that says:

IF

THEN

ELSE


But I'd like to write this program ONCE and then be able to apply it to each of the dozen sensors. If I add a new sensor, I'd like to be able to say:
Apply program "Low Battery" to

So far the only way I've found to do this is literally copy an existing program and change the clauses in there to reference the new sensor. In old-school this is called "copy and paste". The problem with this approach is that if I find a bug in the program, or I want to slightly change how the program works, I need to do that in multiple places instead of fixing it once have having all instances reference the new program.

In THIS case, the programs are not very complicated, so copy-and-paste is not too much of a burden, but as I get to more complicated schemes I'd like to know if I can do the "right programming thing"?

 

Programming the way you want and are accustomed to is different than programming an automation system which is more configuring than programming. These systems have to take into consideration the level of expertise a person may have (for the most part zero programming knowledge).

The copy and paste method is the easiest and quickest way to accomplish what you want. There may be a way with variables and so forth @larryllix but to be honest, it would make things much more complicated and put you in the very situation that you are trying to avoid. 

Link to comment

@lilyoyo1 Thanks -- I was afraid of that.  I'm using Insteon for alarm-like things, including notifications when doors are opened/closed etc..  So I've got literally 10 identical programs where the only difference is the sensor it is monitoring.  E.g.:

If
  'Door Sensors / Basement Door - Door Sensor' Status is On
Then
  Send Notification to 'Door Alerts' content 'Door Opened'
Else
  Send Notification to 'Door Alerts' content 'Door Closed'

Now repeat this for each sensor, replacing 'Door Sensors / Basement Door - Door Sensor' with each unique sensor.

If I combine them together then I don't seem to get individual messages on each open/close of each door.  Although maybe there is a better way to do this where I can combine them all into one program?

Link to comment
24 minutes ago, Derek Atkins said:

I'm an old-school programmer and truly believe in parameterization and the "write once, use many" mode of writing programs. I have a dozen sensors in my Insteon network that I'd like to monitor, and specifically I'd like to monitor them the same way. Basically, I'd like to write a program that says:
. . . .

Hello Derek.......lilyoyo1 is right on. Thought I may pass on my ISY experience as another old schooler.  I think you are referring to a list or array of sensors and having your program index into them.  Unfortunately no you cannot do that.  I have broken my programs up into a main with a "sub program" that does a function like turn on an audible alarm, using the sub program in many other places.  However, I have found that this will delay the sub program action a few hundred ms.  It will also skew the action with other incoming events and may cause a busy processor.  Since I have experienced this, I have changed critical programs to straight inline code with no "sub programs" other than setting variables, etc.  I have also found that adding an "IF" qualification to a folder can cause additional delay.  Good luck.

Link to comment
16 minutes ago, Derek Atkins said:

@lilyoyo1 Thanks -- I was afraid of that.  I'm using Insteon for alarm-like things, including notifications when doors are opened/closed etc..  So I've got literally 10 identical programs where the only difference is the sensor it is monitoring.  E.g.:


If
  'Door Sensors / Basement Door - Door Sensor' Status is On
Then
  Send Notification to 'Door Alerts' content 'Door Opened'
Else
  Send Notification to 'Door Alerts' content 'Door Closed'

Now repeat this for each sensor, replacing 'Door Sensors / Basement Door - Door Sensor' with each unique sensor.

If I combine them together then I don't seem to get individual messages on each open/close of each door.  Although maybe there is a better way to do this where I can combine them all into one program?

They wouldn't be personalised if all were 1 program which defeats the whole purpose.

The copy and paste is the best way to accomplish what you want. 

 

Link to comment
10 minutes ago, KSchex said:

 I have also found that adding an "IF" qualification to a folder can cause additional delay.  Good luck.

Is there a better way to enable/disable all my notification programs en-masse?  Right now I have a folder condition:

If
  $Door_Notifications is not 0
Then
  Allow the programs in this folder to run

I have noticed that there is a delay in when I receive the SMS, but I figured some of that could just be the delay in the SMTP->SMS gateways.

Link to comment
1 hour ago, Derek Atkins said:

Is there a better way to enable/disable all my notification programs en-masse?  Right now I have a folder condition:


If
  $Door_Notifications is not 0
Then
  Allow the programs in this folder to run

I have noticed that there is a delay in when I receive the SMS, but I figured some of that could just be the delay in the SMTP->SMS gateways.

I have some alarms with and without conditional folders to incorporate an enable/disable.  Either way flags or conditional folders you still get a slight delay.  I have tried to minimize using multiple levels of programs, etc. to generate an audible alarm as soon as possible.  In some cases you can't.  It is against my programming ways but here inline is best.

Link to comment
Programming the way you want and are accustomed to is different than programming an automation system which is more configuring than programming. These systems have to take into consideration the level of expertise a person may have (for the most part zero programming knowledge).
The copy and paste method is the easiest and quickest way to accomplish what you want. There may be a way with variables and so forth @larryllix but to be honest, it would make things much more complicated and put you in the very situation that you are trying to avoid. 
Get the multi room MS that can detect motion in x rooms and only use one unit and program with the passed parameters.
:):)

Sent using Tapatalk

  • Haha 1
Link to comment
10 hours ago, Derek Atkins said:

If I combine them together then I don't seem to get individual messages on each open/close of each door.  Although maybe there is a better way to do this where I can combine them all into one program?

If you're not concerned about receiving individual alerts, then you could combine them together and have the alert display the status of each sensor.  That would allow you to have a single program as well as a single alert form.

Link to comment
Guest
This topic is now closed to further replies.

×
×
  • Create New...