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

Is the graphical scene editor buggy


Question

Posted

I'm new to HC2, but I do have a software background. Trying to turn off a light after 5 mins of no motion. The generated Lua code seems way to complex, is there something wrong with this?

 

Device ID 48 = Fibaro motion sensor

Device ID 39 = Fibaro dimmer

 

Thanks!

 

Please login or register to see this code.

 

 

2 answers to this question

Recommended Posts

  • 0
Posted

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

  • 0
Posted (edited)

Hi,

This is Lua code:

--[[
%% properties
48 value
%% events
%% globals
--]]
if (fibaro:countScenes() > 1 ) then
      fibaro:debug("Stop")
    fibaro:abort()
end

local id=48 --Fibaro motion sensor.
local id_relayswitch=80 --Fibaro relay 2 switch.
local id_status={25} --If id 25 (Fibaro relay2 switch) ON, the scene will not run.
local status=tonumber(fibaro:getValue(id, "value"))
local currentDate = os.date("%H:%M");
local begin=0
if status>0 then
  if currentDate> "22:30" or currentDate < "06:00" then --Run from 22:30pm to 06:00am
    for var=1,#id_status do
           local bien=tonumber(fibaro:getValue(id_status[var], "value"))
          if bien>0 then
            begin=1
        end
    end
    if begin==0 then
      fibaro:call(id_relayswitch, "turnOn")
      fibaro:sleep(1*60*1000) --On light 60s
      fibaro:call(id_relayswitch, "turnOff")
    end
  end
end

Edited by signhathongminh

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