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

Hello,

sorry for the newbie question, but could somebody help me with this script, please?  Why it doesnt work?

debug writes only "then expected near ="

Thank you in advance

 

local sensor1 = 21
local sensor2 = 30
 
if sensorID == sensor1 then
    fibaro.alert('push', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' has been activated', false)
    fibaro.alert('email', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' has been activated', false)
 elseif
    sensorID == sensor2 then
    fibaro.alert('push', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' has been activated', false)
    fibaro.alert('email', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' has been activated', false)
else
end
 
 

Recommended Posts

  • 0
Posted

Yes, even motion and door sensors can do that. 

  • 0
  • Inquirer
  • Posted

    ok, thank you

     

    and back to my script ;)

    just for a case, I would like to change message type or for future understanding of LUA language..

    I thought about it and is this a right way to do it?

     

    local sensorsID = {21,112-- smoke sensors
     
    for i=1,#sensorsID do 
     local name = fibaro.getName(sensorsID[i])
     if ( fibaro.getID(sensorsID[i], "") == 21 ) then ---- this line is wrong, but what parameter to get there?
            fibaro.alert('push', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(name) .. ' byl aktivován'false)
            fibaro.alert('email', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(name) .. ' byl aktivován'false)
     
     
    elseif
    .....etc
    • 0
    Posted

    Maybe this example will help, or be of benefit to actually use it. It is a script that checks the status of for example door and window sensors, if they are open or closed. It also has a for i in pairs(sensorIDs) do loop like your are searching for. 

     

     

    Please login or register to see this code.

     

    • Like 1
    • 0
  • Inquirer
  • Posted

    Thank you very much. 

    • 0
    Posted

    Steam comming from boiled water will also activate the smoke sensor.

    //Sjakie

    • Like 1
    • 0
    Posted (edited)
    On 3/11/2021 at 12:36 PM, SmartHomeEddy said:

    Maybe this example will help, or be of benefit to actually use it. It is a script that checks the status of for example door and window sensors, if they are open or closed. It also has a for i in pairs(sensorIDs) do loop like your are searching for. 

     

     

    Please login or register to see this code.

     

    Hi.

     

    I tried this one out today (I Know, it's already posted for a while here), but just want to say "thank you". That helped to solve my challenge ;-)

    Edited by Jupp
    • Thanks 1

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