Motion + light

Moderator: leecollings

Post Reply
DreaMare
Posts: 26
Joined: Friday 03 February 2017 16:45
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Motion + light

Post by DreaMare »

Hi Every One,

after blocky (viewtopic.php?f=62&t=15887). I would like to automate the light using LUA : light turns "On" with motion. But the light still turns "on" even when I get out the room (after shut down light, but the motion record a mouvement so it re-turns on the light ><).

I try out LUA, and i would like to use this code, but I need something "before last seen" to work properly :
Is someone have a clue ?
(and to understand this code is someone can explain what is
year = string.sub(s, 1, 4)
Thank you!

Code: Select all

-- Salon.lua

time = os.date("*t")

t1 = os.time()
s = otherdevices_lastupdate['Motion Salon']
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
absence = (os.difftime (t1, t2))

commandArray = {}


if (devicechanged['Motion Salon'] == 'On' and absence > 300) then

   commandArray['Scene Détente'] = "On"
   
   
end

return commandArray
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest