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

HC2 LUA Scene - Help please. Trying to perform action or get notified when device status has not changed in x minutes


nmins
 Share

Question

Hi,

 

I'm sorry if the question is stupid, or if it is to be found on this forum in an other way, but I spend the last 7 hours struggling... I'm trying to create a LUA scene that will alert me when the garden gate is open for 10 minutes. The reason why I feel stupid about it is that I already have scenes that do exactly this, and they all work fine. The difference with these is that I use door sensors for the scenes that are working and the garden gate has a build in ZWave IBT4ZWAVE.

 

So, in attempt to give something back to whoever can help me, this is a Lua scene that actually works:

 

--------------------------------------- 

--[[
%% properties
100 value
%% weather
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if(startSource["type"] == "other") then
    fibaro:call((fibaro:getGlobal('AaiFoon')), 'sendPush', "Backdoor open for 10 minutes!!" );
else
if (( tonumber(fibaro:getValue(100, "value")) > 0 )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(100, "value");
if (( tonumber(fibaro:getValue(100, "value")) > 0 ) and (os.time() - deviceLastModification0) >= 600) then
    delayedCheck0 = true;
end

local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
    fibaro:call((fibaro:getGlobal('AaiFoon')), 'sendPush', "Backdoor open for 10 minutes!!" );
end
end, 600000)
end
end

---------------------------------------

 

The problem with the GardenGate module is that I want to get a notification whenever the "state" is not "Closed", while the "value" of a door sensor is giving back true or false, which can be converted to numbers (I Think that that is the issue). Unfortunately, I do not understand the initial Lua code very well as I "Copied it with pride" almost 4 years ago, and I cannot find the initial source anymore...

 

I figured that it should not be so difficult to start some kind of 10 minute countdown to an action, that gets canceled if the status changes in the meantime, but that was 7 hours ago ... :-(  

 

So any help from you guru's will be greatly appreciated.

 

Nmins 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Where is the scene that doesn't work?

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi cag014,

     

    Sorry, that was indeed not so smart...

     

    So the scene that is not working:

     

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

    local startSource = fibaro:getSourceTrigger();
    if(startSource["type"] == "other") then
        fibaro:call((fibaro:getGlobal('AaiFoon')), 'sendPush', "Caution! Gardengate open for 10 minutes!" );
    else
    if ((fibaro:getValue(110, "state")) =="Unknown" ) then
    setTimeout(function()
    local delayedCheck0 = false;
    local tempDeviceState0, deviceLastModification0 = fibaro:get(110, "state");
    if (((fibaro:getValue(110, "state")) == "Unknown" ) and (os.time() - deviceLastModification0) >= 600) then
        delayedCheck0 = true;
    end

    local startSource = fibaro:getSourceTrigger();
    if (
     ( delayedCheck0 == true )
    or
    startSource["type"] == "other"
    )
    then
        fibaro:call((fibaro:getGlobal('AaiFoon')), 'sendPush', "Caution! Gardengate open for 10 minutes!" );
    end
    end, 600000)
    end
    end

     

    ____________

    For completeness, also the Device details and the state parameter can be "Unknown", meaning that only 1 door of the gate is open or that the gate is stopped somewhere before the endpoint. It can also be "Opening", "Closing", "Opened" and "Closed", in an ideal world, I would be able to get notified or trigger an other scene if the gate is during 10 minutes anything but " Closed".

     

    { "id": 110, "name": "Gardengate", "roomID": 106, "type": "com.fibaro.baseShutter", "baseType": "com.fibaro.actor", "enabled": true, "visible": true, "isPlugin": false, "parentId": 525, "remoteGatewayId": 0, "interfaces": [ "fibaroFirmwareUpdate", "stepByStep", "zwave", "zwaveAlarm", "zwaveMultiChannelAssociation", "zwaveProtection" ], "properties": { "parameters": [ { "id": 30, "lastReportedValue": 0, "lastSetValue": 0, "size": 4, "value": 0 }, { "id": 31, "lastReportedValue": 100597760, "lastSetValue": 100597760, "size": 4, "value": 100597760 }, { "id": 32, "lastReportedValue": 33488896, "lastSetValue": 33488896, "size": 4, "value": 33488896 }, { "id": 33, "lastReportedValue": 50266112, "lastSetValue": 50266112, "size": 4, "value": 50266112 }, { "id": 34, "lastReportedValue": 83820544, "lastSetValue": 83820544, "size": 4, "value": 83820544 } ], "pollingTimeSec": 0, "zwaveCompany": "", "zwaveInfo": "3,7,13", "zwaveVersion": "7.0", "RFProtectionState": "0", "RFProtectionSupport": "3", "alarmLevel": "0", "alarmType": "0", "categories": "[\"other\"]", "configured": true, "dead": "false", "deadReason": "", "deviceControlType": "63", "deviceIcon": "199", "emailNotificationID": "0", "emailNotificationType": "0", "endPointId": "0", "firmwareUpdate": "{\"info\":\"\",\"progress\":0,\"status\":\"UpToDate\",\"updateVersion\":\"7.0\"}", "localProtectionState": "0", "localProtectionSupport": "5", "log": "", "logTemp": "", "manufacturer": "", "markAsDead": "true", "model": "", "nodeId": "122", "parametersTemplate": "875", "productInfo": "4,65,36,0,16,0,7,0", "protectionExclusiveControl": "0", "protectionExclusiveControlSupport": "false", "protectionState": "0", "protectionTimeout": "0", "protectionTimeoutSupport": "false", "pushNotificationID": "0", "pushNotificationType": "0", "remoteGatewayId": "0", "saveLogs": "true", "serialNumber": "h'0000000000000783", "smsNotificationID": "0", "smsNotificationType": "0", "state": "Unknown", "updateVersion": "", "useTemplate": "true", "userDescription": "" }, "actions": { "abortUpdate": 1, "close": 0, "open": 0, "reconfigure": 0, "retryUpdate": 1, "startUpdate": 1, "step": 0, "stop": 0, "updateFirmware": 1 }, "created": 1650207388, "modified": 1650207388, "sortOrder": 357 }

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • If anybody has any idea's...

    Link to comment
    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
    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.

     Share

    ×
    ×
    • Create New...