Returning Group back to previous setting after trigger

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by pgardiner, Jan 20, 2020.

  1. pgardiner

    pgardiner

    Joined:
    Dec 21, 2004
    Messages:
    32
    Likes Received:
    0
    This is some simple working test code for a gate triggered event to set a long set of drive lights on to 100%. It times OFF when the gate is closed.

    once (GetLightingState("Gate open") = ON) then
    begin
    SetLightingLevel("Drive Lights", 100%, "4s");

    end;

    once (GetLightingState("Gate open") = OFF) then
    begin
    SetLightingLevel("Drive Lights", 50%, "10s");

    end;


    What I really want it to do is return the group “Drive Lights” to the state they were in prior to being tuned on by the event.


    Ie,


    If they were on 40% then return them to 40% after the gate open is OFF


    Hope that makes sense!
     
    pgardiner, Jan 20, 2020
    #1
    1. Advertisements

  2. pgardiner

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,013
    Likes Received:
    78
    Location:
    Adelaide, Australia
    Just save the current light level in a global variable when the gate opens before you set it, and return it to this level when the gate closes.

    Code:
    Globals
    GateLevel: integer;
    
    
    Module
    once (GetLightingState("Gate open") = ON) then
    begin
      GateLevel := GetLightingState("Drive Lights") '
      SetLightingLevel("Drive Lights", 100%, "4s");
    end;
    
    once (GetLightingState("Gate open") = OFF) then
    begin
      SetLightingLevel("Drive Lights", GateLevel, "10s");
    end;
     
    Ashley, Jan 20, 2020
    #2
    1. Advertisements

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.