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

[SOLVED]Turning off light not as simple


amatt

Question

I have a simple Lua script that after no motion (between 2 motion sensors) has been detected for 20 minutes then lights turn off. my script is not working properly the lights keep turning off after a few seconds of the last motion sensor becoming safe. Can someone see what I have done wrong in the script. Thanks!

 

--[[
%% autostart
%% properties
51 value
86 value
%% weather
%% events
%% globals
Day_night
--]]

local startSource = fibaro:getSourceTrigger();
if (
 ( fibaro:getGlobalValue("Day_night") == "Day")
    and  ( tonumber(fibaro:getValue(51, "value")) == 0  and  tonumber(fibaro:getValue(86, "value")) == 0 )
or
startSource["type"] == "other"
  )
then
  
  setTimeout(function()
        fibaro:call(76, "turnOff");
    fibaro:call(78, "turnOff");
    end, 1200)
 
end

Link to comment
Share on other sites

Recommended Posts

  • 0

@amatt Is it possible, your internet router went down or rebooted?

 

You have two distinct errors in your log,

 

1) API: Not found - this one is *probably* quite harmless because code continues to run. It happens, for instance, if your script uses a non-existent global variable.

2) API: Host not found (authoritative) - this one means name resolution failed. It is quite bad, because it crashes code if your code does not expect "nil".

 

The bug exists on HC FW between 4.500 and FW 4.510 (the one available at the time of this post).

 

Issue it was discussed here.

 

I agree with @tinman's diagnosis and I can reproduce the issue:

 

Please login or register to see this code.

My scene crashes at line 106, because fibaro:getValue(10, 'value') returns nil, which is unexpected. You could argue, we should always check if this code returns nil but (1) it actually never happens as long as device 10 exists (on pre 4.5XX firmware) (2) I see no reason why the scene should depend on the availability of the LAN connection.

 

@T.Konopka you closed the topic "API call error when LAN disconnected" as "duplicate", probably because the two errors sound so similar. But I think they are very different.

 

Similar cases

 

 

 

TIP: Search for the word "authoritative" in the error message, to distinguish it from the totally different "API: Not found" error (which is less harmful).

Edited by petergebruers
Link to comment
Share on other sites

  • 0
  • Inquirer
  • @petergebruers my router did not restart it has been up for 33 days now. I just checked it this morning again and it gave me the same error. Hoepefully fibaro can fix this soon.

    Link to comment
    Share on other sites

    • 0
    32 minutes ago, amatt said:

    my router did not restart it has been up for 33 days now

    Thank you for checking that. So we can eliminate this from the list of possible causes. I am certain that LAN disconnects cause this, but I was not sure if that was the cause of your problem. You are certainly not the only one experiencing the "Host not found (authoritative)" error...

    Link to comment
    Share on other sites

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