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

How to


Vallheru

Question

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
 
 
Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • 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)
    Link to comment
    Share on other sites

    • 0

    You could simplify it a bit

     

    Please login or register to see this code.

     

    Didn't tried it, I think this works ?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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
    Link to comment
    Share on other sites

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

    Edited by Vallheru
    Link to comment
    Share on other sites

    • 0

    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. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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. 

     

    Link to comment
    Share on other sites

    • 0

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

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Ah, I thought, you have to create scene ;) 

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

    Link to comment
    Share on other sites

    • 0

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

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 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?

     

    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.

    ×
    ×
    • Create New...