Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Check when switch was last manually used


Question

Posted

Hello!

 

Just started with LUA  and HC2 and have a question. I want to start with somethin really simple. When I enter a room and the motion sensor detects me I want the light to go on. When I leave and there is no movement for 60 minutes I want it to go off again. But if I use the wall switch manually to turn light off or on I want the automatic to be diabled for 12 hours (Dont want light to go on automatically in the guset room if someone sleeps there). I tried with fibaro:getModificationTime(<Id of my wall switch>,'value') but it changes value also when I turn ligts on/off programatically! How can I get the last time the switch was actually used manually? 

 

Best regards, Mikael

 

 

 

7 answers to this question

Recommended Posts

  • 0
Posted

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

  • 0
Posted

Try this script 

I use it . With Babyroom I have switch with double toggle that controls a global sleepmode to Yes or No so the auto light wont go on.

 

 

 

 

  • 0
  • Inquirer
  • Posted

    Ok thanks, but my question was not answered. I want to build something myself to learn how it works and I need a way to detect at what time a switch was manually turned on.

     

    Best regards, Mikael

     

    • 0
    Posted
    On 17 gennaio 2017 at 10:27 PM, Lenfors said:

    Ok thanks, but my question was not answered. I want to build something myself to learn how it works and I need a way to detect at what time a switch was manually turned on.

     

    Best regards, Mikael

     

     

    A good way to learn is to take real examples and understand how they work by reading the code, make small modifications and see the results. Then you can do your own one needed.

    A bad way is to start programming without knowing what to do and how.

    • 0
    Posted
    On 1/18/2017 at 8:27 AM, Lenfors said:

    I want to build something myself to learn how it works and I need a way to detect at what time a switch was manually turned on.

     

    Think I know what you're after as I looked for the same functionality when first using HC2. Short answer, not possible if the switch and light are on the same input/output pair. You will always get the last time the output was modified.

     

    To get what you are after from fibaro:getModificationTime() you need a switch wired to an input with nothing wired to the corresponding output and a device wired to an output with nothing on the input.

    Example using a Fibaro double relay:

    S1 = empty

    S2 = wall switch

    O1 = light

    O2 = empty

     

    Then a scene or association is the only way to control the light from the wall switch but it will effectively give you two device ID's. One for the wall switch and one for the light. Or use the double toggle as @D-Vine mentioned and keep track of the time in a global variable yourself.

     

    It would be a useful feature if there was a device parameter that "disconnects" the input/output pairs and when enabled would provide a different ID for the inputs & outputs for conditional control like this.

    • 0
    Posted

    I agree, not being able to tell the difference between a manual or automatic operation of a device is a problem.    To get around this, I use a global variable in the automatic operation scenes.  I update the global variable with the time when the an automatic operation occurs.  I can then subsequently interrogate the global variable in other scenes together with the GetModificationTime() functions to determine if it was a manual or automatic operation.

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    Ok, tanks Siddler.

    This is a real pain as I always want manual switches to override all automatics. I can't understand how the system can't handle such a basic functionality!?

    I'll try to do as you suggested, but this means two global variables extra for each switch....

     

    Best regards, Mikael

     

     

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...