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

os.date between hour


Question

Posted

HI,

 

I have a problem

 

I use a my scene to arm and disarm my alarm system.

 

It works.

 

But now, I want the siren sound 1 second when I arm my alarm, but not between 07:00 AM and 09:00 AM.

 

But my code failed.

 

This is the code:

 

-- Set formato data local

Adesso       = os.date("%H:%M")

local InizioSilenzio     = "07:00"

local FineSilenzio         = "09:00"

 

fibaro:debug(Adesso)

if

   (Adesso  > InizioSilenzio and Adesso < FineSilenzio)    

then    

  fibaro:debug("Attivo sirena")

  fibaro:call(53, "turnOn");  

  setTimeout(function()    

  fibaro:call(53, "turnOff");     

  end, 1000)

else

  fibaro:debug("No Sirena")

end

 

The test failed and the result is "No Sirena" everytime.

 

 I tried to change the hour's range but nothing to do.

 

Where are I wrong?

 

2 answers to this question

Recommended Posts

  • 0
Posted

Hi @MarcoTorino71,

 

when i run your code with Adesso set:

Please login or register to see this code.

then i get the output:

Please login or register to see this image.

/monthly_2020_01/image.png.67a1f898e4ce25bb4163bad2abb31fd9.png" />

When i set it outside the range, i get:

image.png.b73573910c0f8cb3649018a39384e897.png

So your code seems to work properly :-)

 

  • 0
  • Inquirer
  • Posted

    I had forgotten "local"  ...

    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...