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


Question

Posted

Looking for some help for the following unknowns (all in lua):

 

- setting a (predefined) variabele after system reboots/restarts

- setting dimlevels without turning them on (for example: setting previous dimlevels next time when 1 or more lights turned on)

- check if local sensors {32,64 etc} turned on/of, without coding 1 of them

- values current ram, cpu1 and cpu 2 for usage in a VD

 

Sorry for my bad english, but i hope someone can help me out

 

rick

7 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Anyone? Kinda stuck:)

    • 0
    Posted

     

    • 0
    Posted

    local startSource = fibaro:getSourceTrigger()
    local sensors = {501,71,72,66}

    Debug = function ( color, message )
    fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
    end

    total_OpenClosed = 0
    for i=1, #sensors do
    Sensor = tonumber(sensors)
    value_Sensor = fibaro:getValue(Sensor, "value")
        if value_Sensor ~= "0" then
            total_OpenClosed = total_OpenClosed + 1
        end
    end
    if tostring(total_OpenClosed) > "0" then
        Debug("red", "Total of active sensors = "..tostring(total_OpenClosed))
    else
        Debug("green", "No active sensors")
    end

     

    • 0
    Posted

    --[[
    %% autostart
    %% properties
    %% globals
    --]]

    local startSource = fibaro:getSourceTrigger()
    if fibaro:getGlobalValue("HC2") == "Running" then
        fibaro:setGlobal("HC2", "Restart")
        fibaro:debug("Fibaro HC2 have Restarted!")
        fibaro:setGlobal("HC2", "Running")
    end

     

     setting dimlevels without turning them on (for example: setting previous dimlevels next time when 1 or more lights turned on)

     

    Set it in a global en cal this global when needed

    • 0
  • Inquirer
  • Posted

    Thanks Kage!

    • 0
  • Inquirer
  • Posted
    On 7/5/2019 at 2:58 AM, Kage said:

    local startSource = fibaro:getSourceTrigger()
    local sensors = {501,71,72,66}

    Debug = function ( color, message )
    fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
    end

    total_OpenClosed = 0
    for i=1, #sensors do
    Sensor = tonumber(sensors)
    value_Sensor = fibaro:getValue(Sensor, "value")
        if value_Sensor ~= "0" then
            total_OpenClosed = total_OpenClosed + 1
        end
    end
    if tostring(total_OpenClosed) > "0" then
        Debug("red", "Total of active sensors = "..tostring(total_OpenClosed))
    else
        Debug("green", "No active sensors")
    end

     

     

    I tried above, but my debugwindow only giving the first mentioned sensorID. What i wanne accomplish is:

     

    local sensor = {79, 102, 107, 50}

       if( ( (tonumber(fibaro:getValue(50, "value")) > 0 
                 and tonumber(fibaro:getValue(50, "armed")) > 0) or
              (tonumber(fibaro:getValue(79, "value")) > 0 
                 and tonumber(fibaro:getValue(79, "armed")) > 0) or
              (tonumber(fibaro:getValue(102, "value")) > 0 
                 and tonumber(fibaro:getValue(102, "armed")) > 0) or
              (tonumber(fibaro:getValue(107, "value")) > 0 
                 and tonumber(fibaro:getValue(107, "armed")) > 0) ) and
              hc:getGlobalValue(houseAlarm)==houseAlarmMapping.Armed and
              hc:getGlobalValue(presentState)~=presentStateMapping.Home and
              hc:getGlobalValue(alarmState)==alarmStateMapping.Safe)
          then

         -- for example
          fibaro:debug("Breached")
    end
    end
    end

     

    can you help me out with this @Kage?

     

    Thanks in advance

     

    Rick

    • 0
    Posted (edited)

    Try this

     

    local startSource = fibaro:getSourceTrigger()
    local sensors = {79, 102, 107, 50}

    Debug = function ( color, message )
    fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
    end

    Sensors = function()
          total_breached = 0
        for k,v in ipairs(sensors) do
            if     (tonumber(fibaro:getValue(v, "value")) == tonumber(0) or 
                  tonumber(fibaro:getValue(v, "armed")) == tonumber(0)) and
                  hc:getGlobalValue(houseAlarm)==houseAlarmMapping.Armed and
                  hc:getGlobalValue(presentState)~=presentStateMapping.Home and
                  hc:getGlobalValue(alarmState)==alarmStateMapping.Safe then
              else
                  Debug("red", fibaro:getName(v).." in the "..fibaro:getRoomNameByDeviceID(v).." is triggerd")
                  total_breached = total_breached + 1
            end
        end
    end

    if startSource["type"] == "property" then
          Sensors()
          if total_breached == 0 then Debug("green", "no breach") end
    end

     

     

    or try this

     

     

    local startSource = fibaro:getSourceTrigger()
    local sensors = {79, 102, 107, 50}

    Debug = function ( color, message )
    fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
    end

    Sensors = function()
          total_breached = 0
        for k,v in ipairs(sensors) do
            if     (tonumber(fibaro:getValue(v, "value")) == tonumber(0) or 
                  tonumber(fibaro:getValue(v, "armed")) == tonumber(0)) then
              else
                  Debug("red", fibaro:getName(v).." in the "..fibaro:getRoomNameByDeviceID(v).." is triggerd")
                  total_breached = total_breached + 1
            end
        end
    end

    if startSource["type"] == "property" then
          Sensors()
          if     total_breached == 0 and
            hc:getGlobalValue(houseAlarm)==houseAlarmMapping.Armed and
            hc:getGlobalValue(presentState)~=presentStateMapping.Home and
            hc:getGlobalValue(alarmState)==alarmStateMapping.Safe then 
                Debug("green", "no breach") 
          end
    end

    Edited by Kage

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