Change push button action depending on current state

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • Gast

    #1

    Change push button action depending on current state

    Sorry it's not in German, but replies can be :-)
    I have the following situation : a room with a push button for light, and a motion sensor. This motion sensor keeps the light on for X minutes, and only does so when it's dark outside
    I was wondering, how to implement that :
    - You turn on the light with 1 click on the push button (normal behavior)
    - You turn off the light with 1 click on the same push button regardless how the light was switched on.
    That means that if the motion sensor switched on the light, single click on the button now should:
    - disable the sensor
    - switch off the light
    In other words, a click on the button always switches the state of the light
    Seems straightforward, but I don't know how the GUI logic is translated into code and I notice that attaching an input to do both at the same time, doesn't seem to work.
    The setup is :
    INPUT => Tr on push button to light + R on timer for motion sensor + Dis on motion sensor
    ​Light goes off but comes on again straight away...

    ​I hope I am making any sense, or at least enough to get some ideas :-)

    Thanks!
  • Christian Fenzl
    Lebende Foren Legende
    • 31.08.2015
    • 11234

    #2
    Hi casaben,
    I'm not on the computer to post a screenshot, so I try it in words.
    You can use the OUTPUT of the push button to change the behaviour of the INPUT using AND's.
    For example, if INPUT pressed AND OUTPUT, trigger the R of the push button (and time logic of the motion sensor).
    If INPUT pressed AND NOT OUTPUT, trigger the O of the push button.
    Regards, Christian
    Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

    Kommentar

    • J V
      LoxBus Spammer
      • 28.08.2015
      • 367

      #3
      Zitat von casaben
      ​Light goes off but comes on again straight away...
      It is not switched on again by the motion sensor? :-)

      Kommentar

      • Christian Fenzl
        Lebende Foren Legende
        • 31.08.2015
        • 11234

        #4
        Please show your current implementation ;-)
        Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

        Kommentar

        • Gast

          #5
          Hi guys,
          @ JV : yep and that's what I'm trying to avoid by disabling the motion sensor at the same time you switch the light off when the motion sensor enabled it.
          @ Christian : will try asap, no access right now, but what you describe is what I tried but doesn't seem to work out that well, the logic processes the sequence in a strange way...
          But I'll give it another try, do some tests to determine how the miniserver handles the sequence of commands.

          Thanks already,

          Ben

          Kommentar

          • Gast

            #6
            Here is the situation.
            This circuit should work ok, but what happens is that :
            - Button pushed, and disables the motion sensor
            - But since the motion sensor is disabled, it allows pass through of the signal to the switch, and the light goes on (not through motion sensor but through push button)

            The problem is that I need to toggle the state of a flag AND use the 'old' flag value at the same time.
            The logic apparently executes the update of the flag first, and then only evaluates the push button part.
            If only it would do it the other way around :-)
            I might put in a delay somewhere, but that seems a lot of programming to realize a rather simple idea...
            Thought about flip-flops etc, but I don't see a nice way to implement this...
            Hope that makes it easier :-)

            This is a simplification of what I'm dealing with, a mock-up, but the problem should be clear.
            - Motion sensor only turns on light when it's enabled.
            - Push input should switch on/off light when motion sensor is disabled, and only switch off motion sensor when that one is enabled, but not touch the state of the push button. So it has 2 different assignments depending on the state of the motion sensor.

            The motion sensor has its own clock and will fire retrigger signals if motion remains, so I cannot hook it up to the Tr since light will go on/off all the time.

            Right now I did it with multiclick, 1 click controls light and 2 clicks enable/disable motion sensor. Works perfect, but this is just something I think would be easier for people who are unaware of our setup :-)
            Zuletzt geändert von Gast; 18.02.2016, 20:26.

            Kommentar

            • J V
              LoxBus Spammer
              • 28.08.2015
              • 367

              #7
              Sounds a bit similar to a problem I had with a thermostat setting: I wanted to be able to set the mode of the thermostat on the wall unit (knx), but also using a radio button. Of course, I wanted the display on the thermostat and the radio button to both show the current state, and it resulted in a loop. At the moment I don't have access to my config, but I stored the current state. I used a memory flag to store the current state:
              -
              IF (mode on wall unit != mode on radio button) then // comment: one of them changed
              IF (mode on wall unit == mode in memory flag) then update mode in wall unit // comment radio button changed
              END IF
              IF (mode on radio button == mode in memory flag) then mode in radio button // comment wall unit changed
              END IF
              END IF

              IF (mode on wall unit == mode on radio button) then // comment: one of them changed
              update memory flag
              -

              I had to trigger the update of the radio button upon the boot of the system, to have a good startup procedure.

              Perhaps you can achieve something similar: store the current state of the light and compare with then one....

              Kommentar

              • Christian Fenzl
                Lebende Foren Legende
                • 31.08.2015
                • 11234

                #8
                Gast, is your motion sensor input a pulse or is it on as long as the light should be on?
                Hilfe für die Menschen der Ukraine: https://www.loxforum.com/forum/proje...Cr-die-ukraine

                Kommentar

                • Gast

                  #9
                  The motion sensor input signal is high as long as motion is detected (repeatable trigger), so not just a single pulse and then blocked for X seconds of refiring.
                  If I use the non-refire mode, doesn't work well with the Loxone for one or the other reason...

                  Kommentar

                  • Gast

                    #10
                    try using Lighting Controller and scenes. My example:
                    Button push change the scene to light on and disables the motion detector. Second push enables again the motion detector and switch the light off. Motion detector is also enabled and disabled by other button and by timer. For your case you should just add some AND operators with inputs from button and AQs output, that can than modify the behavior to your specific needs.

                    Kommentar

                    Lädt...