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

Need your help on basic LUA coding please.


Question

Posted

Hello all, 

 

so I am setting up my house & used Block Scenes for standard on/off by sensor & day/time activity scenes, coupled with standard day/night & awake/asleep variables.  all is going OK but getting adventurous, i wanted to try & include LUX decision into auto light switching on & off & it will not work for the life of me..  Can someone review & help me get this right please: 

 

2-3 days ago in Block Scene creation: working on the variable 'Awake' (between 08:00am to 9:00pm each day) depending on the LUX being below '5' in my master bedroom, i wanted the  triggering Fibaro PIR sensors in the 'foyer, bedroom or the wardrobe' to activate the bedroom floor light for 60 seconds powered by an Aeotec Z-wave Plus Smart Switch 6..  

 

Please login or register to see this image.

/monthly_2019_07/image.png.30d4a9b8d4da33d23762948980756bbd.png" />

 

The light triggered by the PIR's being breached, works & the light turns "ON" & 60 seconds later turns "OFF" -- but the 'Awake' Variable & 'Lux' setting of less than or equal to '5' does not seem to have any control.  Last night outside the awake timeframe, the light kept triggering when motion detected by the PIR's.  Also: Yes the variable awake is working as another light routine is controlling correctly <does not turn on during this time-frame> & the LUX for Bedroom at this time is reporting back as 18 __ so the light should NOT be turning on because of Lux.

 

I have checked HC2 location & time is correct & I have reset the Energy Metering just in case per some other forum questions. 

 

I took the plunge & transferred a copy of the scene above into LUA and have been learning, investigating on:

 

--[[
%% autostart
%% properties
151 value
131 value
149 value
107 value
%% weather
%% events
%% globals
Awake
--]]

local startSource = fibaro:getSourceTrigger();
if (
 ( fibaro:getGlobalValue("Awake") == "Yes" )
and
 ( tonumber(fibaro:getValue(151, "value")) <= 5 )
and
 ( tonumber(fibaro:getValue(131, "value")) > 0 )
or
 ( tonumber(fibaro:getValue(149, "value")) > 0 )
or
 ( tonumber(fibaro:getValue(107, "value")) > 0 )
or
startSource["type"] == "other"
)
then
    fibaro:call(269, "turnOn");
    setTimeout(function()
        fibaro:call(269, "turnOff");
    end, 60000)
end

 

I think it is correct & but the Problem continues --  can anyone tell me what I am doing wrong please or any adjustments to make this scene work only when dark per LUX setting & during the 'awake' variable time-frame..??

Thank you in advance for any guidance or assistance.

 

Cheers AH.

 

 

 

Please login or register to see this attachment.

2 answers to this question

Recommended Posts

  • 0
Posted

IMHO issue in combination of OR and AND operation without right order of “(“ “)”

Can’t  help sorry, do not clear understand your logic, but you may reorder and/or operation with grouping  () according your logic

 

Please login or register to see this link.

 

 

  • 0
  • Inquirer
  • Posted
    On 7/15/2019 at 7:52 PM, 10der said:

    reorder and/or operation with grouping  ()

    @10der - thank you & it worked - bit of a re-arrange of the 'or' command & '( )' & - now the scene is working  .  i appreciate the guidance. 

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