Script Enabling/Disabling

Discussion in 'C-Bus Automation Controllers' started by MikeEco, Jul 23, 2019.

  1. MikeEco

    MikeEco

    Joined:
    Jun 23, 2008
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney
    Hi All,

    Need a bit of assistance please, how do i force this script to run when enabled.

    value=GetTriggerLevel(002)

    if value==0 then
    SetTriggerLevel(000, 003)
    elseif value==1 then
    SetTriggerLevel(000, 004)
    elseif value==2 then
    SetTriggerLevel(000, 005)
    elseif value==3 then
    SetTriggerLevel(000, 006)
    end

    Any help would be appreciated.
    Thanks Mike
     
    Last edited: Jul 23, 2019
    MikeEco, Jul 23, 2019
    #1
  2. MikeEco

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Not sure what you mean here. Are you trying the enable/disable the script programatically, or just get it to run when Trigger Group 2 changes?

    As an aside, you can replace all that with

    Code:
    SetTriggerLevel(000, GetTriggerLevel(002) + 3)
     
    Ashley, Jul 24, 2019
    #2
  3. MikeEco

    MikeEco

    Joined:
    Jun 23, 2008
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney
    Hi Ashley,

    Yes wanted it to run when it was enabled, changed it from event based to resident and it now works.

    Thanks for assistance.
     
    MikeEco, Jul 29, 2019
    #3
  4. MikeEco

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    If you run this as a resident based script it will be issuing Cbus commands every time the script executes. You don't say how often you are running this but if it's every few seconds or less you are continuously outputting a lot of data which is not a good thing.

    It should be an event based script set up on Trigger GA 2. That way the script will only run when the trigger level changes.
     
    Ashley, Jul 29, 2019
    #4
  5. MikeEco

    MikeEco

    Joined:
    Jun 23, 2008
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney
    It is currently running once every 60 seconds only when enabled. the issue i was having was once the script was enabled it wasnt checking to see if trigger 002 had changed.
     
    MikeEco, Jul 29, 2019
    #5
  6. MikeEco

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Were you enabling the script manually or programatically? It seems to work fine for me as an event based script.
     
    Ashley, Jul 30, 2019
    #6
  7. MikeEco

    MikeEco

    Joined:
    Jun 23, 2008
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney
    Script was enabling after event, if the trig changed whilst enabled it worked fine but it wouldn't react when enabled if no change.
     
    MikeEco, Jul 30, 2019
    #7
  8. MikeEco

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I see. You wanted the script to run immediately it was enabled to update its state. Unfortunately events don't work like this. Personally I think event based scripts should run when first saved or enabled as you want them set up the initial conditions. Might be a good suggestion for a future update (assuming there are any :().

    I'm curious as to why you need to disable and enable it continuously?
     
    Ashley, Jul 31, 2019
    #8
  9. MikeEco

    MikeEco

    Joined:
    Jun 23, 2008
    Messages:
    22
    Likes Received:
    0
    Location:
    Sydney
    this is a bar that has set schedules that trigger scenes when open, otherwise they are in staff mode (Full lighting). when they open (times differ everyday week to week) they need the correct scene to activate.
     
    MikeEco, Jul 31, 2019
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.