Jump to content

Ask for Scene by Lua


Recommended Posts

Hi guys I ask for Lua scene to control the lights automatically into star's by motion detection bt problem not for that 

The problem is I want that scene work between 6 pm to 7am and if motion detection don't detect any move then turn off light after 20 minutes 

Any one hare can help my to do that 

 

 And Thanks for every one 

Link to post
Share on other sites

You can do it with All-in-One Scene and many other actions... you can find an examples how to use it in

https://forum.fibaro.com/topic/48263-all-in-one-scene-how-to-do-it-better/

Here is the solution for you:

jS2n={stairMS=404,stairLight=394} --please change stairMS and stairLight to your real device ID

jM={
{5,"`stairMS`",{state="value=true",timeSlot="18:00~07:00",timeSpanOn=true,
trueAct={"`stairLight`","turnOn",""},
timeLoopAct={"`stairLight`","turnOff","","{`stairMS`:valueModified>1200|`stairLight`:value=true}"}}},
}

The light will turn off if no motion detected within 20-25 minutes.

Edited by cag014
Link to post
Share on other sites

--[[
%% autostart
%% properties
%% events
%% globals

--]]
jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

jM = {{
{5,"stairMS",{state="value=true",timeSlot="18:00~07:00",timeSpanOn=true,
trueAct={"stairSoptLight","stairHiddenLight","turnOn","",""},
timeLoopAct={"stairSoptLight","stairHiddenLigh","turnOff","","",
{"stairMS:valueModified>1200|stairSoptLight,stairHiddenLigh:value=true"}}}

}

 

C1.PNG

Edited by mohamedsalah
Link to post
Share on other sites
jM = {
{5,"`stairMS`",{state="value=true",timeSlot="18:00~07:00",timeSpanOn=true,
trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
}

Please pay attention that any device name should be within back apostrophe ` (located on same key with ~)

Edited by cag014
Link to post
Share on other sites
25 minutes ago, cag014 said:
jM = {
{5,"`stairMS`",{state="value=true",timeSlot="18:00~07:00",timeSpanOn=true,
trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
}

Please pay attention that any device name should be within back apostrophe ` (located on same key with ~)

I have edited the post probably after you have saw it...

Edited by cag014
Link to post
Share on other sites
  • 2 weeks later...

What's defrant between that scene 

 

--[[
%% autostart
%% properties
110 value
266 value
263 value
%% events
%% globals

--]]
jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

jM = {
{5,"`stairMS`",{state="value=true",timeSlot="17:00~07:00",timeSpanOn=true,
trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
}
And that scene 

 

--[[
%% autostart
%% properties
110 value
%% weather
%% events
%% globals
--]]

local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(110, "value")) > 0  and  (math.floor(os.time()/60)-math.floor(1582381980/60))%60 == 0 )
)
then
    fibaro:call(263, "turnOn");
    fibaro:call(266, "turnOn");
end

setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else

local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(110, "value")) > 0  and  true )
or
startSource["type"] == "other"
)
then
    fibaro:call(263, "turnOn");
    fibaro:call(266, "turnOn");
end

end

 

The images for scend scene

The target for the first one is make light on if motion detection detact any move from 17 pm to 7 am and if no motion after 20 minutes the light it will be off but the code is run success but light don't work

Scand scene light work but all the time in day 

Wath should I do to solve this problem problem 😅🤔

Screenshot_20200225_170328_com.android.chrome.jpg

Link to post
Share on other sites
10 minutes ago, mohamedsalah said:

but the code is run success but light don't work

Do you mean that lights don't turned ON?

What exactly doesn't work?

 

Regarding block scene: Looks OK, but you need to create another block scene that turns lights off when sensor back to safe

Edited by cag014
Link to post
Share on other sites

Are you sure it work at all or shows an error?

The reason to my question is that you have typo error

jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

jM = {
{5,"`stairMS`",{state="value=true",timeSlot="17:00~07:00",timeSpanOn=true,
trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
}

instead stairHiddenLigh it should be stairHiddenLight. Missing 't'

Link to post
Share on other sites

Regarding block scene: Looks OK, but you need to create another block scene that turns lights off when sensor back to safe. It should be a same scene. Replace Breached to Safe,  TurnON to TurnOff and set 1200 s

Spoiler

Capture.thumb.PNG.1e43e817baa8557563f5e5352aa65bae.PNG

 

Edited by cag014
Link to post
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
Reply to this topic...

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