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

[SOLVED] How to get scene ID within it's code


Sankotronic

Question

@T.Konopka, @I.Srodka, @A.Socha or anyone with advanced knowledge

 

For virtual devices there is function that can give us ID number within VD code: fibaro:getSelfId()

 

QUESTION: Is there any similar function to get scene ID within it's code?

 

EXPLANATION: I need to find scene ID within it's code. I don't have any references when scene is installed on user HC2. I know that I can use scene name that has to be unique and then search it within response from API call, but that solution is far from good. What if user misspell name or decide that he like to use different name?

Edited by Sankotronic
Link to comment
Share on other sites

Recommended Posts

  • 0

There is no such function.

 

I may submit it as a suggestion for a new feature but that doesn't mean it will be implemented.

Link to comment
Share on other sites

  • 0

Agree, really miss that one...

In version 4.140 that I'm running (don't know about later versions) there is an undocumented variable "__fibaroSceneId" available inside scenes... maybe while you wait for the official function?

 

  • Thanks 1
Link to comment
Share on other sites

  • 0

Well, Sankotronic being in the home automation software business supporting many users on many versions may need to be a bit cautious with this, or have some kind of fallback strategy...

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • 6 hours ago, I.Srodka said:

    There is no such function.

     

    I may submit it as a suggestion for a new feature but that doesn't mean it will be implemented.

     

    Hi @I.Srodka,

     

    This is very important feature and you should definitely suggest your team to seriously consider it or at least leave "__fibaroSceneId" as a part of the system. Distribution of future "out of the box" solutions depend on such features and gives developers possibility to make solutions that will not require end users to have any programming skills to install and use them. This can only benefit to Fibaro system in the end.

     

    6 hours ago, jgab said:

    Agree, really miss that one...

    In version 4.140 that I'm running (don't know about later versions) there is an undocumented variable "__fibaroSceneId" available inside scenes... maybe while you wait for the official function?

     

     

    Hi @jgab,

     

    Thank you for sharing this undocumented feature. BTW there are lot more functions and features that are not documented on Fibaro developer website.

    Link to comment
    Share on other sites

    • 0

    So, whenever I install a new version I run this in a scene to understand what's available (btw, anyone using the logger?)... (something similar for VDs)

    Please login or register to see this code.

     

    • Like 4
    Link to comment
    Share on other sites

    • 0

    but how you extract the __fibaroSceneId from this table??

    It seems to change everytime I run the printTable code....

    Thanks.

    Link to comment
    Share on other sites

    • 0

    Well, you don't need to extract it. Just conclude that it is there and use it in your scene.

    Please login or register to see this code.

    The _ENV contains all global variables (incl. functions) available in the Lua environment you are given.

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    3 minutes ago, jgab said:

    Well, you don't need to extract it. Just conclude that it is there and use it in your scene.

    Please login or register to see this code.

    The _ENV contains all global variables (incl. functions) available in the Lua environment you are given.

     

    Great!!! 

    I were supposing the need to extract it from a system table... instead it is ready to use yet... 

    many many thanks!!!

    Link to comment
    Share on other sites

    • 0

    __fibaroSceneId exists since 3.907, and it's still being user by Fibaro, but as they cleaning up the code who knows how long it will stay ...

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, tinman said:

    __fibaroSceneId exists since 3.907, and it's still being user by Fibaro, but as they cleaning up the code who knows how long it will stay ...

     

    I hope it will stay till the end of days or at least be replaced with function fibaro:getSlefId() that is available in VD. Being able to get scene ID from it's code opens door to a real automation where user setup within code can be reduced to a minimum.

    Link to comment
    Share on other sites

    • 0

    Well, you could always do something like this...

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 12/18/2017 at 7:12 AM, jgab said:

    Well, you could always do something like this...

     

    Hi @jgab,

     

    I though about that solution, but adding this loop to all scenes which ID is needed is not the best choice. It can slow down performance. Maybe adding unique name in scene code and then use separate initialization scene that will make global variable table with all scenes ID and unique name? Unique name then can be used to retrieve scene ID when needed in another code.

    Link to comment
    Share on other sites

    • 0

    For long running scenes that extra time shouldn't be a problem, for short trigger scenes it can be ”cached” the first time around

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    • 0

    Is it possible to get the scene ID of the scene that was used to trigger another scene?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 2 hours ago, RossA said:

    Is it possible to get the scene ID of the scene that was used to trigger another scene?

     

    In scene that calls other scene you can use this code to provide calling scene ID:

    Please login or register to see this code.

    Then in scene that was started by above code you can get scene ID 'sId' with this code:

    Please login or register to see this code.

    Same way you can send virtual device ID to the scene that was started by that VD.

     

    • Like 2
    Link to comment
    Share on other sites

    • 0

    Thank you very much.

     

    I am new at this and while I have now have written many scripts and learned a lot, I am still not familiar with the finer detail of LUA.  First time I have done any coding.

     

    All worked well thanks again.

    Link to comment
    Share on other sites

    • 0

    Do you mind if I ask you one more question?

     

    Is it possible to send email notification from LUA, from alarm scene, that has the device ID that triggered alarm?  I know you can send pre defined messages but it would be great if I could use the email address already in the HC2, the one used to send pre defended messages, but be able to customise the message.

     

    Also, I suppose this makes it 2 questions sorry, as you know when a sensor triggers it may send ,multiple message while it is in alarm state, is there a way of limiting the message to one message per trigger.  That is set a time period where if triggered again within a time period it will not send another message.  Sensor trigger -> send message -> no more messages within xxSeconds -> then send new trigger message.

     

     

     

    Link to comment
    Share on other sites

    • 0

    Ok I worked email out, need to test if I can limit the number of messages sent if sensor alarm period causes extra messages.

     

    thanks.

     

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