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

Activate a named scene from another scene (=Lua)


tieske

Question

I have a scene that gets activated properly, but depending on the conditions I have multiple other scenes that contain the details.

Now I would like to activate the detail scenes by their name. I serached the api docs but couldn't find it.

Consider this;

Please login or register to see this code.

If this scene where named "sample", then the scene "sampleLarge" and "sampleSmall" would get executed depending on "some_value".

any ideas?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Then you need to use json.decode to get the id from the json located at:

Please login or register to see this code.

Based on the name of the scene. Google "fibaro json decode" and it will show you some examples of the use of json decode.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Tried something based on code found

    Please login or register to see this link.

    But it gives me an indexing nil value error. Could it be that the `Net` namespace is not available in a scene? (only in a virtual device)

    Link to comment
    Share on other sites

    • 0

    Yes... You need a virtual device to do the mechanics. Use a button in the device to run the code in.

    Then the scene pushes the button and the device save the id to a global variable and import it into the scene.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hmmm, that's not where I want to go.

    What I'm trying to solve is this; using a Zwave.me WCD2 device, configured as a scene controller. It has 2 buttons, each up and down. And each "pressurepoint" has 4 interactions (click, dbl click, hold, release).

    So I have 2 x 2 x 4 = 16 possibilities

    Instead of creating 16 Lua coded scenes, I want 1 scene per device that handles the input and then calls other scenes (not necessarily Lua) to execute the actions. As I intent to have a bunch of those devices, I want them automatically named.

    So, one scene, called "MySwitch", handles the inputs and then calls dynamically named sub scenes;

    Button 1 click; calls name.."btn1click" --> scene MySwitch_btn1click

    Button 1 dblclick; calls name.."btn1double" --> scene MySwitch_btn1double

    So per device I create 1 Lua scripted scene, and all others can just be created, provided they are named correctly. Easy from a managment pespective.

    Now if I have to create a virtual device, a bunch of globals and then some scenes, it becomes a management nightmare. I'd be better of just adding the core Lua code to each scene, and code everything in Lua (which I don't want actually)

    Is there some alternative way to do this?

    Thijs

    btw; thx for your time on this! really appreciated

    Link to comment
    Share on other sites

    • 0

    You only need one virtual device with one button and two globals:

    First action:

    You press a button to activate "btn1double"

    One global handles the name of the input, so it is set to the name of the button function "MyScene_btn1double" is saved to the first variable

    Second action:

    The scene presses the button of vdXX. VdXX then imports the global and splits it into two parts: "MyScene" and "btn1double". My scene is converted into an id based on the imported json(sceneID YY), and the btn1double is converted to an integer from 1 to 16 (one for each of the 16 combinations), ZZ and the two numbers are then recombined to one string separated by an underscore "YY_ZZ" and saved to a global (you could the same global as for importing to the vd)

    Third action:

    The scene then imports the global variable back in and splits it up into a scene id and runs scene YY ("MyScene")

    Fourth action:

    "MyScene" activates the subscene based on the value ZZ in the global variable. Whether this be a fubction inside MyScene or yet another scene doesn't matter.

    But the short of it is, that since fibaro doesn't support the net function from scenes, you need a virtual device to take care of that part of the communication and then send the info back into the scene for further processing. So it just takes one vd and one or two globals to do that.

    It is generally a good idea though to keep as much as possible in as few scenes as possible as many scenes can affect the performance of your homecenter.

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