Announcement

Collapse
No announcement yet.

General question for script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • General question for script

    Hi,

    I know really little about scripting. But I would like to clarify something.

    When using the event engine without script in HS3.. You have to put a first ''iff'' to trigger the event.


    But if you create a script ''starting'' with If, ...- Is that triger from a scrip able to trigger the script itself... or it as to be trigered by a first if from the event engine ?In that case.. the if from the script became virtually a condition.

    So logic is:

    A ''if trigger'' from the event engine trigger the script as an action.


    so there is no way to run a script without using the event engine? ( eg: the device call the script directly, when the first ''if'' of the script is satisfied)

    thank you.


    last question: if you compare, for example, a ''perfectly written script'' witch take the role of 3 events , and both options have exactly the same functions- Witch option will use less PC resources?

  • #2
    Originally posted by Summerguy View Post
    . . .if you create a script ''starting'' with If, ...- Is that triger from a scrip able to trigger the script itself... or it as to be trigered by a first if from the event engine ?
    A script has to be running before it can respond to an If-Then situation. A script in HS cannot 'start' itself. The normal way to start a script is with the event action 'Run a script or script command'. Once running, the script will be able to detect and take action based on changes - to the value of an HS device, for example.
    so there is no way to run a script without using the event engine? ( eg: the device call the script directly, when the first ''if'' of the script is satisfied)
    The only other way that I can think of to run a script in HS is at program start. The most direct way would be to run an event from the Startup script that would run a special script that consisted of an 'idle loop' which would contain a variety of If-Then constructs. (It is probably possible to modify the Startup script itself to add the idle loop at the end, instead of in a separate script, thus avoiding the use of an event.) In essence, such a loop would replicate/replace some functions of the HS event engine. It is a method older automation systems often used. I can't think of a reason to do it in conjunction with HS, but I know of at least one person who did something along those lines in HS2.
    if you compare, for example, a ''perfectly written script'' witch take the role of 3 events , and both options have exactly the same functions- Witch option will use less PC resources?
    I don't think there is a way to definitively answer that question. The definition of a ''perfectly written script" is the first problem.

    Using the HS event engine seems to me to be the much easier method, in any case.
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      Originally posted by Summerguy View Post
      Hi,

      I know really little about scripting. But I would like to clarify something.

      When using the event engine without script in HS3.. You have to put a first ''iff'' to trigger the event.


      But if you create a script ''starting'' with If, ...- Is that triger from a scrip able to trigger the script itself... or it as to be trigered by a first if from the event engine ?In that case.. the if from the script became virtually a condition.

      So logic is:

      A ''if trigger'' from the event engine trigger the script as an action.


      so there is no way to run a script without using the event engine? ( eg: the device call the script directly, when the first ''if'' of the script is satisfied)

      thank you.


      last question: if you compare, for example, a ''perfectly written script'' witch take the role of 3 events , and both options have exactly the same functions- Witch option will use less PC resources?
      I see what you want to do, but a script is really a set of code that runs AFTER an event has occurred. The system does not pre-read your scripts and consider the first statements and automatically matches that to system events, you need to do that yourself.

      Now your condition can be unrelated to the script. Need to do something every once in a while? Launch a script every 10 minutes, no need to have an IF there. Another example, for my pool I launch my temperature control script any time the solar, water, or air temperature changes. That causes it run numerous times a day. The script itself figures out what needs to occur (turn heater on, etc) but the trigger to launch it is any over those devices changing value.

      Comment


      • #4
        Thank you to both of you.

        that answers my questions

        Comment


        • #5
          There is a way to run a script other than through an event. You can define a device's properties so that when it's value or status changes, it automatically runs a script specified for that device. Probably won't help you, but you never know.

          tenholde
          tenholde

          Comment

          Working...
          X