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

Notifications


StarkJohan

Question

1. Is it possible to get the content of a predefined notification in LUA?

2. Is it possible to change the value of a notification on the fly via LUA?

3. What is the difference between global and defined? Se code below:

Please login or register to see this code.

Link to comment
Share on other sites

Recommended Posts

  • 0

StarkJohan,

Following code:

Please login or register to see this code.

Sends/Pushes "Predefined" notification number 1 to to your device id 15.

You SHOULD define notification text in "Notifications" panel and then you can use blocks to create scene with it. You can not have idea of lua script, if you want.

Please login or register to see this code.

This code sends text "Push test". It can be changed to any variable. It can be used only in LUA script editor, not by blocks.

IMHO.

"sendGlobalPushNotifications" i don't know.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks. I didn't know about the possibility to push manually.

    I also found out how to send email manually:

    Please login or register to see this code.

    That's all fine and dandy but doesn't answer my questions. Is is possible to get and/or change defined notifications via LUA?

    I've setup my own sms-gateway and I would like to be able to access predefined notifications, that way I could "replace" the missing SMS function.

    Link to comment
    Share on other sites

    • 0

    What do you mean by "defined notifications"?

    Check Notification Panel

    Please login or register to see this image.

    There you can create as many as you need notifications, and then choose them in device properties or in scene block editor or in your code.

    Link to comment
    Share on other sites

    • 0

    He wants to do it in LUA

    Not sure if it is possible....

    i do it like this, easy to change text, variable etc.

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Yes, I know. These are the predefined notifications. I can manually edit them and that is fine but not what I'm asking.

    I would like to know if it is possible to get these predefined notifications into a LUA script so that I can use the notifications any way I want and not just the standard push/email commands (which I know how to do in LUA).

    E.g. something like this:

    Please login or register to see this code.

    and/or this

    Please login or register to see this code.

    Do you see what I mean?

    Link to comment
    Share on other sites

    • 0

    no, i can't understand.

    Can you describe whole idea?

    "I come home, turn on dimmer1 and then my wife get push notification" is done via usual way

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Long story short. I have an sms gateway virtual device used in this way:

    Please login or register to see this code.

    This sends an sms via the gateway. I can use any message I want but I would like to use the predefined ones if possible. That way I could send sms notifications straight from the block scenes without using LUA and that would be more user friendly.

    Link to comment
    Share on other sites

    • 0

    StarkJohan,

    Have you ever received any "predifened SMS" from your HC2? I guess there is none.

    All text should be entered by admin.

    Why you want to call them "notifications" instead of just variables?

    You can edit global variables from interface, you can modify them in blocks, you can access them in scripts, is't it?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Notifications setup in the notifications panel == predefined notifications. They are PREVOIUSLY DEFINED manually in the web GUI, not on the fly using LUA which is what I want to do. But mostly I just want to access them in LUA.

    Global variables are set in the variables panel. These can be modified and accessed by LUA and block scenes. However, these CAN'T be STRINGS, only NUMBERS which is rather useless in this case.

    Global predefined variables can be accessed but not changed by LUA. This could be an alternative in my case but that would not be as nice as to be able to use the "real" notifications.

    If you still don't see what I mean, I give up.

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    Link to comment
    Share on other sites

    • 0
    Global variables are set in the variables panel. These can be modified and accessed by LUA and block scenes. However, these CAN'T be STRINGS, only NUMBERS which is rather useless in this case.

    Global Variables can also be strings...change one of them i.e.x by fibaro:setGlobal("var", "string")

    Before define var in variables panel.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Cool, it actually works as richo states. Wonder if it's a bug in the GUI or what the intension with the globals really is.

    Any way, that's another way to do this, just like using labels but still not quite what I'm asking. I guess modifying or using the predefined notifications wasn't fibaros intension. It would be nice to have these available as long as no SMS services are available in any other country than PL.

    Link to comment
    Share on other sites

    • 0

    Kind a strange behavior. I can put text in global variable, and I can see that text in variables panel. But when I try to edit it - no luck, just digits allowed.

    Link to comment
    Share on other sites

    • 0

    You can set the global variable with fibaro:setGlobal("test","string") and use it in LUA, but if you go to variables panel, edit, delete or add any variable, when you save, your global variable that is not numeric gets replaced with NaN (Not An Number).

    It seems that Fibaro designed the variables to be ONLY numeric.

    In my opinion, they are almost useless like this...

    Link to comment
    Share on other sites

    • 0
    In my opinion, they are almost useless like this...

    if you want to use a panel to edit strings in variables then agree, but if you use LUA it's a great tool. I use it for hundreds of reasons in different scenes

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    One of them i.ex. makes a log of all activated scenes with their names and places them in mysql database for analysis.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • BTW, it's possible to set a global var to a string from LUA but the var has to be previously declared. I cannot declare and set a new global var from LUA. I have to agree with MorpheusRO.

    Link to comment
    Share on other sites

    • 0
    BTW, it's possible to set a global var to a string from LUA but the var has to be previously declared. I cannot declare and set a new global var from LUA. I have to agree with MorpheusRO.

    Exactly! If you want to define a new variable, when you save it, all non numeric variables that you already have get reset...

    Please login or register to see this image.

    /emoticons/default_icon_confused.gif" alt=":-?" />

    Link to comment
    Share on other sites

    • 0

    Just found it:

    Please login or register to see this link.

    returns you the notifications

    Please login or register to see this link.

    returns you one notification with it's texts

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Fantastic! Thanks a bunch.

    HC2 is a pretty awesome system, I just hope that the documentation gets updated on all the available functions a.s.a.p.

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" /> *hint hint* *nudge nudge*

    Maybe a wiki-part of the forum would be helpful. That way we could document these "hidden" functions.

    Link to comment
    Share on other sites

    • 0

    Yeah I was looking for the z-wave logs when you add or remove a device and then bumped into this. I rembered you searching for it. So it actaully took me some serious digging in the javascript to get it

    Please login or register to see this image.

    /emoticons/default_tongue.png" alt=":P" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> and I don't even think they hide it on purpose

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    The logs are at:

    Please login or register to see this link.

    I hadn't though of your way to use the notifications. But I think it is better than putting it in enums

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

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