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

I think you can remove the else

  • 0
  • Inquirer
  • Posted

    Thank you for reply Eddy. Error disappeared, but it did nothing. I didnt get any push or email notification. Single (below) condition works fine

       local sensorID = 21
        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)
    • 0
    Posted

    You could simplify it a bit

     

    Please login or register to see this code.

     

    Didn't tried it, I think this works ?

    • 0
  • Inquirer
  • Posted

    My condition works too, but I have problem with if nad elseif variables,
    not with fibaro.alert trigger

    I can create it as a many simple scenes, but I would like to create one scene, which contains all of my smoke sensors and on depend, which sensor is active, it will send message with sensor name.

    How to get variable sensor1, sensor2 etc to the variable sensorID

     Thank you

     

     

    • 0
    Posted

    Can you publish the complete code?

    • 0
  • Inquirer
  • Posted

    yes

    {

      conditions = { {
          id = 21,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        }, {
          id = 112,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        } },
      operator = "any"
    }
     
     
    _____________________________________________________________________________________________________________________________
    ACTIONS
    _____________________________________________________________________________________________________________________________
     
     
    local sensor1 = 21
    local sensor2 = 112
     
    if sensorID == sensor1 then
        fibaro.alert('push', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' activated', false)
        fibaro.alert('email', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' activated', false)
    elseif sensorID == sensor2 then
        fibaro.alert('push', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' activated', false)
        fibaro.alert('email', {[1] = 2, [2] = 32, }, ''.. fibaro.getName(sensorID) .. ' activated', false)
    end
    • 0
    Posted

    OK, I thought there was more ?

     

    sensorID is nothing 

    • 0
  • Inquirer
  • Posted

    Eddy, could you help me to fix it , plese? I have no idea :(

     

     

    • 0
    Posted

    I think you try to send a message when one of your (two) motion sensors is breached?

    • 0
  • Inquirer
  • Posted (edited)

    yes, message with sensor name, which has been acivated. (that are smoke sensors)

    Edited by Vallheru
    • 0
    Posted

    Then I would take the easy road. With only two sensors, make a block scene for each sensor. If the sensor is breached, send specific message. 

    • 0
  • Inquirer
  • Posted

    yes, but this is what I do not want, because sensors will be much more and I would like to have only one scene, as I wrote before. 

     

    • 0
    Posted

    I understand you don't receive the standard notifications when breaching your smoke sensors or you are not satisfied with the content?

    • 0
  • Inquirer
  • Posted (edited)

    Maybe I do not understand your last question. But, it is simple. 

    I would like to create one scene with many sensors

    If some sensor will activate itself, scene will run, and by the  sensor ID, send me a message with sensor name.

     

    Why to create x same scenes, when you can create only one?

     

    This is not possible to create via block scenes, therefore I need to put variable "sensor id" to the body of the message. That's all ;)

    Edited by Vallheru
    • 0
    Posted

    Like this

     

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    you do not need to create a scene if you have set this parameters?

    It always send me a notification, when any of sensor detect a smoke?

    • 0
    Posted

    Yes, it should. You can test is with some smoke. Burn some wood (not your house :-) )

    • 0
  • Inquirer
  • Posted

    Ah, I thought, you have to create scene ;) 

    What message and which users are the recipients of the message?

    • 0
    Posted

    (That is why I tried to figure out what you wanted to achieve, not in the first place how.)

     

    Depending on the user settings:

     

    Please login or register to see this image.

    /monthly_2021_03/image.png.0db995ed76293526d3035f42a65d20db.png" />

     

    image.png.33edcaf6353ef124ea540765474c4ac7.png

     

    It will send the notifications to your users. 

     

     

    • 0
  • Inquirer
  • Posted

    good to know. so if I understand:

    all sensors, witch have parameter "notifications" can send message (push, email, etc) directly without LUA or BLOCK scenes

    That means all smoke, fire, flood, CO sensors?

     

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