Gå til innhold
  • Bli medlem
Støtt hjemmeautomasjon.no!

Twinznavy

Medlemmer
  • Innlegg

    1
  • Ble med

  • Besøkte siden sist

Innlegg skrevet av Twinznavy

  1. Hei. 

     

    Kan noen hjelpe meg med en LUA kode, er helt grønn i dette.

    Jeg har Fibaro HC2. 

    Jeg ønsker å lage en kode som tar høyde for variablene Dag/Natt 

    Lys ved  "natt" settes til 20 % ved bevegelse på fibaro motion sensor og er på i 3 min før det slås av. 

    Lys ved "dag" settes til 100 %  ved bevegelse på fibaro motion sensor og 15 min før det slås av. 

     

    Har funnet en kode som virker, for av og på men sliter med å få inn variablene Dag og Natt. 

     

    --[[
    %% properties
    106 value
    174 value
    %% globals
    --]]
    -- CHANGE ABOVE VALUES 24 AND 27 TO MOTION DETECTOR AND LIGHT SENSOR ID!
    if (fibaro:countScenes()>1) 
     then
     fibaro:abort();
    end 
    local getGlobalValue = Natt
    local motid = 174 -- ID for the motion detector
    local luxid = 176 -- ID for the light sensor
    local dimid = 106 -- ID for the dimmer you want to operate
    local light = 10000 -- Lux level below which motion will trigger the light on, if lights should always turn on with motion set at 10000
    local ondim = 20 -- Determines what light setting the light will start at

    if (tonumber(fibaro:getValue(motid, "value"))) > 0 and (tonumber(fibaro:getValue(luxid, "value")) < light) and (tonumber(fibaro:getValue(dimid, "value")))<1 then
     local starttimer =60; -- Determines how long the light will stay on before dimming starts
     local timer = (starttimer)+ondim;
     local dimout=ondim;
     fibaro:call(dimid, "setValue", dimout);
     fibaro:debug("Lights on at level "..dimout);
     repeat
       fibaro:sleep(1000);
       --below if condition will turn the light off if the wall switch is pressed and
       --timeout for 10 seconds to avoid the scene retriggering due to motion in the
       --room.
       if (tonumber(fibaro:getValue(dimid, "value"))) < 1 then
         timer=1;
         fibaro:call(dimid, "turnOff");
         fibaro:debug("Light switched off manually, time out for 10 seconds");
         fibaro:sleep(10000);
         break
       end
       fibaro:call(dimid, "setValue", dimout);
       timer=timer-1;
       --below if condition will reset the timer and the dim level to initial values if
       --motion has been detected since last sleep period. This means that as long as 
       --there is movement in the room, the light will remain lit.
       if (tonumber(fibaro:getValue(motid, "value"))) > 0 then
         timer=starttimer+ondim;
         fibaro:debug("Motion detected, reseting timer");
         dimout=ondim;
       end
       
       fibaro:debug(timer);
     until (timer<1)
     --Once the timer has finished and dimlevel reaches 1, the light will be turned off
     fibaro:call(dimid, "turnOff");
     fibaro:debug("Lights out");
     --Change below number to the id of the scene 
     fibaro:killScenes(95);
    end

     

×
×
  • Opprett ny...

Viktig informasjon

Vi har plassert informasjonskapsler/cookies på din enhet for å gjøre denne siden bedre. Du kan justere dine innstillinger for informasjonskapsler, ellers vil vi anta at dette er ok for deg.