Help; macro to control manual light switch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Paul_B
    Automated Home Legend
    • Jul 2006
    • 608

    Help; macro to control manual light switch

    I am after some help with creating a macro or other solution to control a light from a light switch as well as automatically from sensors. Sounds more simple than it is as I'll try to explain.

    Automatic light control defined by light level sensor, time of day, presence and timer.

    Manual input from digital switch.

    The automatic side works fine, someone enters, its dark, the right time of day the light turns on. They leave and presence removed, light goes off.

    Now to explain what I am trying to do with the manual input from the switch. Basically it should be able to override the current light state regardless of other conditions. So if the light is off and the switch operated the light should come on (regardless of time of day or light level). If the light is on then it can be turned off immediately by pressing the button. However, if the light is left on then the automated presence removal should turn it off after the timer period.

    Now the main problem I have is the macro functionality doesn't allow for state interrogation or extended logic. So I can't do something like.... if light is off then turn on...

    I have made some progress by using two macros; one to switch light on, one to turn light off, both macros are always running and registered against the light condition change. The continuing problem is that when the light conditions would normally have the light off and it is manually turned on the override flag is set and doesn't get reset. Therefore, automatic control no longer works (lights will turn on even when they should be off due to time of day or light level when presence is detected)

    Paul
    Last edited by Paul_B; 9 January 2008, 12:05 AM.
  • Gumby
    Moderator
    • May 2004
    • 437

    #2
    So if I understand correctly, when you first press the button it enters an override state, on or off depending on prior state, a subsequent button press clears the override, but there is also an timeout that cancels the override period.

    Or did you mean the second press retains the manual override, but toggles the overridden state ?

    I think we are about to explore the detailed logic of the override vs toggle actions ... I note that the latest help has some additional notes covering these.

    I have a suspicion that you may want to just apply a toggle on the light from the button, and may be enable auto clear override on period change.

    But I'm not sure I've entirely understood your desired scheme.
    ----------------------
    www.gumbrell.com

    Comment

    • Gumby
      Moderator
      • May 2004
      • 437

      #3
      So I've just done a quick experiment and I think you just want to set the button to toggle the light. Toggle is sort of intelligent, in that it is exactly a toggle when the light is set to manual, but "does the right thing" when the light is automated in some way.

      Using override actions can confound the logic since the response depends on presence and the button press can create presence depending where it is.

      Have a play with behaviour panels for the room, the light and the button all open at the same time so you can see the status and simulate presence/no presence. I seem to have noticed some changes to the light behaviour panel in particular to help clear up confusions round this topic.

      Or I've misunderstood the requirement :-)
      ----------------------
      www.gumbrell.com

      Comment

      • JonS
        Automated Home Guru
        • Dec 2007
        • 202

        #4
        I am with David here. I think if you just use Toggle it should work. That is how my lights are set-up and if the light is forced on then presence is still required to keep the light lit.

        My expierence in this area is using macros to create scenes. forcing state to "on" or "off" kinda works but if someone walks past a light sensor then other lights in the room can automatically switch on. I think the way around this is to set the scene wih lights "enabled" / "disabled" but I think I'd also need a macro to run at end of day to sent everything back to normal. I also need to experiment with having fewer of the light channels set to automatic and use manual control instead as this may help. There is also Toggle and Synchronise which I came across recently. Lots of options, not so much time!

        ATM I am reflex programming default light settings as SWMBO doesn't like it if Cortex PC doesn't work and she cannot change the lights
        JonS

        Comment

        • Paul_B
          Automated Home Legend
          • Jul 2006
          • 608

          #5
          Thanks for the advice guys. I am sure I tried the toggle function initially but it didn't quite do what I wanted. However, I didn't make notes at the time and now can't remember what was wrong.

          I'll re-try this again tonight and this time make some notes!

          The one thing that maybe strange with this particuliar light is it is in an ensuite location. The actual switch is in the next room.

          I'll describe some specifics tonight when I get home.

          Paul

          Comment

          • Karam
            Automated Home Legend
            • Mar 2005
            • 863

            #6
            The automated lighting logic is a good example of how something that might be perceived to be 'easy' is actually quite complex because when you sit down and analyse different peoples' requirements you sometimes find that you need some sort of mind reading facility. Take a simpler example of heating adjustments: Someone is perhaps feeling a bit cold and requests a set point increase from the system, sounds simple enough, but then how long should that set point increase persist? Remember we are talking about automation here so its a bit of a failing if the user has to remember to go and reduce the setting at some later time and this is further complicated by the fact that the system will likely be following a profiled set point curve so it may not be so obvious later on that the setting has been increased. Its the same with lighting - you get some situations where the user is effectively saying they want the automation turned off or mode changed - but how long for? Should they have to remember to then turn it back on? Worse still - someone else later walks into room and automation does not respond as expected. When you get used to automation even occasional incidents of it not working as expected feel worse than not having automation in the first place.

            Cortex uses heuristics to try and second guess peoples intentions, but even so I can tell you that in the new release of Cortex you will likely see a revised lighting engine which is perhaps more complicated to 'play with' but provides better user access to the automation parameters and some new heuristics.

            Karam
            IDRATEK LTD

            Comment

            • chris_j_hunter
              Automated Home Legend
              • Dec 2007
              • 1713

              #7
              Help; macro to control manual light switch

              sorry, slight aside :

              magic ... Kevin asked a while back why I went with Idratek, and I found it difficult to give a short reply ... but this is exactly it ... ie: Karam & his colleagues do actually understand the problem, do understand what automation needs to be, and are making it happen !
              Our self-build - going further with HA...

              Comment

              • Paul_B
                Automated Home Legend
                • Jul 2006
                • 608

                #8
                Heuristics is a word I have come across a number of times, but I am not sure I really understand it. Can anyone give a simply explanation as to what heuristics is?

                Paul

                Comment

                • JonS
                  Automated Home Guru
                  • Dec 2007
                  • 202

                  #9
                  JonS

                  Comment

                  • Paul_B
                    Automated Home Legend
                    • Jul 2006
                    • 608

                    #10
                    Back to the original topic of the thread. I have tested disabling the macros I am using and setting the light input to toggle.

                    Situation:
                    Operating period = valid
                    Light level = dark (therefore, light should come on)
                    Light switch pressed
                    Light comes on
                    Add presence, light stays on
                    Remove presence, light goes off after timer countdown

                    The above situation works as I want.

                    Now to describe what doesn't work how I want.

                    Situation:
                    Operating period = valid
                    Light level = dark (therefore, light should come on)
                    Light switch pressed
                    Light comes on
                    Add presence, light stays on
                    Remove presence and immediately press light switch
                    Light goes off immediately (as I want)

                    However, the override flag gets set on the light object. The override then doesn't clear so if I walk back into the room presence detection doesn't turn the light on because of the override flag still being set.

                    Paul

                    Comment

                    • JonS
                      Automated Home Guru
                      • Dec 2007
                      • 202

                      #11
                      So you want to be able to manually switch the light off on exiting a room but for it to come on again as soon as you re-enter??

                      I've not tried this but could you run a macro to re-set override if the light has been forced off?
                      It runs every n-minutes same as the light timeout.
                      If the light is off and override set set a flag
                      If flag set when macro starts, clear override.

                      This won't work if you return within the time for the marco to run twice.

                      2p
                      Jon
                      JonS

                      Comment

                      • Paul_B
                        Automated Home Legend
                        • Jul 2006
                        • 608

                        #12
                        The problem with your suggestion is I couldn't find a way to interrogate the current setting of the light. So I can't "ask" Cortex if the light is on / off or if the override flag is set or unset.

                        Also the override interface through the macro is a toggle function itself. Therefore, I can't set an unclear option. If the override flag is set then addressing override will clear the flag. However, if the override is not set addressing override will now set it.

                        I am thinking about using the API interface to script what I am trying to achieve as I can then interroagte the current values and status and apply IF, Then, Else or Select Case logic. Over option is to wait until the end of February ;o)

                        Paul

                        Comment

                        • JonS
                          Automated Home Guru
                          • Dec 2007
                          • 202

                          #13
                          I've only glanced across the help for the Logic objects but it may help if you haven't looked there already. It suggests you can read the state of an object but a quick look for a light object isn't terribly clear cf a door object.
                          HTH
                          Jon
                          JonS

                          Comment

                          • Gumby
                            Moderator
                            • May 2004
                            • 437

                            #14
                            I get the feeling that on the way in you are trying to either allow for old habits or beat the presence detection and on the way out you are trying to override the timeouts - I guess I cheated and taught SWMBO that if she presses the light switches and the red light is then on she has to press it again for automation to work :-)

                            Thinking laterally - can you shorten the ensuite light timeout to something acceptable ? Does the ensuite have a door and is presence working reliably ?
                            ----------------------
                            www.gumbrell.com

                            Comment

                            • Gumby
                              Moderator
                              • May 2004
                              • 437

                              #15
                              It's tricky and as you have found, you can't interrogate the override state. You can sort of interrogate the light state by starting macros on set-on/set-off, or waiting on the set state output, but I think your problem here is the interaction of toggle with presence.

                              For override to come on in a toggle to off, I think presence has to be true at the time of the button press. So this implies that presence doesn't get cleared before the button is pushed - perhaps the door is not closed first, or you don't have a door or door switches ? If this was consistent we could infer that override is set on an exit press and cancel it by toggling the override.

                              But if presence is indeterminate on the exit press then we can't infer the override state and know how to cancel it. So this implies to me that the macro would have to instead disable the light, perhaps wait for the timeout period and then re-enable.

                              Then you have to solve the problem of returning to the ensuite whilst the light is disabled :-)
                              ----------------------
                              www.gumbrell.com

                              Comment

                              Working...
                              X