Multiple lights controlling central extract system

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by lennyb, Jun 15, 2014.

  1. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    I have a manual ventilation system and it has an extract boost function. This is triggered by a c-bus relay. I want to set it up so that turning on the in shower spots in any of the 3 bathrooms starts the boost after 1 minute of the shower light remaining on. Once the light is turned off it stays on for a further 10 minutes then switches the boost off again. If any of the other shower lights are turned on after the first then this should be taken into account so if that light is turned of after the first one then the 10 minutes kicks in for the last of the lights to be turned off. I thought I'd use a delay for the start up and turn off but I'm not so sure.

    This is my code which seems to work great when testing it in the PICED software, but when I transfer it to my PAC and test it from there the boost channel doesn't behave as it did in the PICED testing.

    Code:
    // check if any of the 3 shower lights are turned ON
    once (GetLightingState("House Bathroom Shower") = ON) or
         (GetLightingState("Guest Bathroom Shower") = ON) or
         (GetLightingState("Master Ensuite Shower") = ON) then
    begin
      
      Delay("0:01:00");  //add 1 min delay before starting fan
     
    // check again that the lights stayed on for 1 min then start boost
     if (GetLightingState("House Bathroom Shower") = ON) or
         (GetLightingState("Guest Bathroom Shower") = ON) or
         (GetLightingState("Master Ensuite Shower") = ON) then
     begin
       SetLightingState("MVHR Boost", ON);
     end;  
    end;           
    
    //MVHR boost turning off after all shower lights are off and a delay of 10 mins
    once (GetLightingState("House Bathroom Shower") = OFF) and
         (GetLightingState("Guest Bathroom Shower") = OFF) and
         (GetLightingState("Master Ensuite Shower") = OFF) then
    begin
       Delay("0:10:00"); //10 min delay before switching off
    //Check all shower lights remain off then switch off
     if (GetLightingState("House Bathroom Shower") = OFF) and
         (GetLightingState("Guest Bathroom Shower") = OFF) and
         (GetLightingState("Master Ensuite Shower") = OFF) then
     begin
       SetLightingState("MVHR Boost", OFF);
     end;   
    end;
                                    
    
    Would a timer be better for the 10 min wait rather than a delay?

    I'm new to this so still learning the best methods.

    Thanks
     
    lennyb, Jun 15, 2014
    #1
  2. lennyb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Alternatively:

    Code:
    if conditionStaysTrue(GetLightingState("House Bathroom Shower") = ON, 60) then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0); 
    if conditionStaysTrue(GetLightingState("Guest Bathroom Shower") = ON, 60) then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0); 
    if conditionStaysTrue(GetLightingState("Master Ensuite Shower Shower") = ON, 60) then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0); 
    Pulsing a group that is already on will just reset the pulse time to the new value.
     
    Ashley, Jun 16, 2014
    #2
  3. lennyb

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    The problem with using a delay in logic land from my understanding is it effectively pauses that module for the delay period at that point, so thus a timer or Ashley's solution would be a better option.. This may be why you are seeing unexpected results..
     
    Roosta, Jun 16, 2014
    #3
  4. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    OK, the condition stays true look good I'll try that out tonight. I think a timer is the better option, don't like to think what the behaviour will be if the module is paused for the 10 min delay and someone turns another shower light on somewhere!
     
    lennyb, Jun 16, 2014
    #4
  5. lennyb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Actually I just realised my code doesn't do quite what you asked for as it runs the fan for 10 minutes after any light has been on for 1 minute, whereas you wanted it to run on for 10 minutes after the last light was turned off. However the idea is still the same using conditionStaysTrue for the on test and pulsing the fan for the time delay. The conditionStaysTrue is used to turn the fan on, and the oulse happens when the last light is turned off:

    Code:
    if conditionStaysTrue(GetLightingState("House Bathroom Shower") = ON, 60) then
       SetLightingState(MVHR Boost", ON);
    if conditionStaysTrue(GetLightingState("Guest Bathroom Shower") = ON, 60) then
       SetLightingState(MVHR Boost", ON);
    if conditionStaysTrue(GetLightingState("Master Ensuite Shower") = ON, 60) then
       SetLightingState(MVHR Boost", ON);
    
    once (GetLightingState("House Bathroom Shower") = OFF) and
         (GetLightingState("Guest Bathroom Shower") = OFF) and
         (GetLightingState("Master Ensuite Shower") = OFF) then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0);
    
    Using delays in logic is generally to be avoided as it pauses to entire module for the delay time. Whenever you need a group to be on for a certain length of time the PulseCBusLevel is the way to go.
     
    Ashley, Jun 16, 2014
    #5
  6. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    That looks great. Just tried it out and in PICED the testing was perfect but when I transfer it to my PAC the AND logic for turning off fails, I've had trouble with lighting states and ands to check if they are all off in the past.

    Any ideas why the PAC doesn't like the ANDs?
     
    lennyb, Jun 16, 2014
    #6
  7. lennyb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    The PAC is the only logic device I haven't used so I can't really help there.
    You could try re-arranging the logic and see what happens. GetLightingState returns a boolean so you don't rally need to compare it with on/off. (It's just easier to read). So you can re-write it as:

    Code:
    once (GetLightingState("House Bathroom Shower") or
         GetLightingState("Guest Bathroom Shower") or
         GetLightingState("Master Ensuite Shower")) = FALSE then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0);
    or:

    Code:
    once not (GetLightingState("House Bathroom Shower") or
         GetLightingState("Guest Bathroom Shower") or
         GetLightingState("Master Ensuite Shower")) then
      pulseCBusLevel("LocalNetwork", "Lighting", "MVHR Boost", 100%, 0, 600, 0);
    I'd be surprised if it made any difference though.

    Perhaps someone from Clipsal can throw some light on it for us.
     
    Ashley, Jun 17, 2014
    #7
  8. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    I've tried a few ways to check multiple states together, ands and ifs and they all work in the PICED software, but as soon as I transfer them to the PAC they no longer work.

    If I strip out the multiple conditions and have just one then it works again, so somewhere by using multiple conditions to check the states of more than one group it fails.

    Any ideas Clipsal people? My PAC is on firmware version 3.80.0
     
    lennyb, Jun 17, 2014
    #8
  9. lennyb

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Can you put up your current code?
     
    Roosta, Jun 17, 2014
    #9
  10. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    This is what I was using, worked in PICED not PAC.

    Code:
    if conditionStaysTrue(GetLightingState("House Bathroom Shower") = ON, 60) then
       SetLightingState("MVHR Boost", ON);
    if conditionStaysTrue(GetLightingState("Guest Bathroom Shower") = ON, 60) then
       SetLightingState("MVHR Boost", ON);
    if conditionStaysTrue(GetLightingState("Master Ensuite Shower") = ON, 60) then
       SetLightingState("MVHR Boost", ON);
    
    once (GetLightingState("House Bathroom Shower") = OFF) and
         (GetLightingState("Guest Bathroom Shower") = OFF) and
         (GetLightingState("Master Ensuite Shower") = OFF) then
      pulseCBusLevel(254, "Lighting", "MVHR Boost", 100%, 0, 600, 0%);
    
    
    Turning the boost on works great, but when I turn off the shower lights the pulse doesn't trigger. If I remove the ands and have just one state check then the pulse does work.
     
    lennyb, Jun 17, 2014
    #10
  11. lennyb

    Roosta

    Joined:
    Nov 22, 2011
    Messages:
    560
    Likes Received:
    1
    Location:
    Australia
    Is that all of your code?

    Have you got appropriate 'begin' and 'end' statements within your module?
     
    Roosta, Jun 17, 2014
    #11
  12. lennyb

    lennyb

    Joined:
    Feb 25, 2013
    Messages:
    41
    Likes Received:
    0
    Location:
    UK
    That's the whole thing in the module
     
    lennyb, Jun 17, 2014
    #12
  13. lennyb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Just for interest, try moving the conditions outside of the ONCE statement.

    Code:
    Global section:
    
    lightState: boolean;
    
    Module:
    
    lightState := GetLightingState("House Bathroom Shower") or
         GetLightingState("Guest Bathroom Shower") or
         GetLightingState("Master Ensuite Shower") ;
    
    once lightState = OFF then
      pulseCBusLevel(254, "Lighting", "MVHR Boost", 100%, 0, 600, 0%);
     
    Ashley, Jun 17, 2014
    #13
  14. lennyb

    conor1

    Joined:
    Feb 13, 2007
    Messages:
    135
    Likes Received:
    0
    Location:
    Northern Ireland
    Hi ,
    I'm just trying out similar logic and when I add time to "= on, 60 ) I get
    error code coo6 at line 53:61 - illegal symbol
    Error code c129 at line 53:65 - type conflict of operands
    When I remove ,60 it compiles am I missing something very obvious
    Thanks in advance
    Conor
     
    conor1, Oct 6, 2016
    #14
  15. lennyb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Not sure what you mean. Can you post the whole line.
     
    Ashley, Oct 6, 2016
    #15
  16. lennyb

    conor1

    Joined:
    Feb 13, 2007
    Messages:
    135
    Likes Received:
    0
    Location:
    Northern Ireland
    Hi Ashley ,
    Have it worked out I had for got to use conditionStaysTrue before (getlightingstate(
    All working great now
    Thanks
    Conor
     
    conor1, Oct 6, 2016
    #16
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.