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

Scene ID


Rosavision

Question

HC3 v 5.120.10

 

I have a simple table that I update if the scene number changes for a given scene. 

 

Scene_ID = 

{Move_Lounge ={ID=155, version="2.1"},

Etc

Etc

}

 

I want get the scene to update the table itself if its ID changes.

 

To do this I need to get the Scene ID and I can’t figure out how to do it !

 

 @jgab I found a thread where you helped someone to get the scene name with the following

 

fibaro.debug(tag,api.get("/scenes/"..sceneId).name)

 

But what I want is to get the scene ID number

 

I know it will be something simple, but I can’t figure it out!

Edited by Rosavision
error
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 1

You need to map the name to the id? 

 

Either

Please login or register to see this code.

 

or if you loop trough many names it can be worth caching the map

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi @jgab Pairs is new to me, so thank you for your help. I've been using tables a lot since you helped me a few months ago, now I learn about pairs. This is a great help.

    Link to comment
    Share on other sites

    • 0
    On 10/28/2022 at 2:26 PM, Rosavision said:

    To do this I need to get the Scene ID and I can’t figure out how to do it !

     

    To simple get the ID of the current scene, use the predefined variable sceneId like:

    Please login or register to see this code.

     

    Output:

    [29.10.2022] [22:47:14] [DEBUG] [SCENE35]: 35

    Link to comment
    Share on other sites

    • 0
    9 hours ago, Joep said:

     

    To simple get the ID of the current scene, use the predefined variable sceneId like:

    Please login or register to see this code.

     

    Output:

    [29.10.2022] [22:47:14] [DEBUG] [SCENE35]: 35

    I thought about that but it seemed like he wanted to make a table (HT) of scene Ids, and then he needed name->id mapping.

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
    Just now, jgab said:

    I thought about that but it seemed like he wanted to make a table (HT) of scene Ids, and then the he needed name->id mapping.

    ?

    Link to comment
    Share on other sites

    • 0

    As a note.

    One can do 

    Please login or register to see this code.

    to get the device/QA with the name "Foo" (actually, there can be many)

    However, we can't do

    Please login or register to see this code.

    as it gives an 501 error (not implemented)

    So, the api is not as generic as one would expect....

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi @jgab and @Joep

     

    I really appreciate your help and I’ve been trying the example code you sent me. What I realise is that I didn’t do a very good job of explaining the problem I’m trying to solve. All the code you helped me with works perfectly, but it doesn’t quite solve the problem!!

     

    When I update the code for a scene eg a lighting scene triggered by a movement sensor, I create a new “master” version eg Move_V3.1 and I retire the old version Move_3.0 by hiding it

     

    Then I create new lighting scenes for the house eg Move_Lounge_v3.0 [with scene ID 104], becomes Move_Lounge_3.1 [with scene ID 155]. I then “retire” the old scene by turning it off and hiding it. 

     

    Use Case

    Sometimes I need another scene to kill the Move_Lounge_3.1 and I’ve been using scene ID’s in the code of the “killing scene”, which works fine. But because the scene ID for Lounge_Move has changed from 104 to 155, the “killing scene” doesn’t work. To get around this I have lots of admin to update all the “killing scenes” with the correct ID’s to kill.

     

    So I’ve created a simple table which I save as a Json variable which has the scene name (without version number), the scene ID and the version number

     

    Scene_ID = { 

     

    Move_Lounge ={ID=155, version="version_3_1"},

    Move_Kitchen_H ={ID=117, version="version_3_1"},

    Move_Entry ={ID=118, version="version_3_1"},

    Move_Bathroom ={ID=119, version="version_3_1"},

    Move_Utility ={ID=120, version="version_3_1"},

    Etc

    Etc

    etc

    }

     

    Then when I want to kill a scene eg Move_Lounge_3.1 the scene “killing scene” uses the scene name eg Move_Lounge to gets its most current ID from the Scene_ID table and then kills it

     

    But I still have to do admin to keep the Scene_ID table updated !!

     

    So (when triggered) I want to get the Move scenes to check to see if their own ID’s  match the Scene_ID table and if not, then the scene will update the Scecne_ID table itself.

     

    To do this the Move scene needs to get its own ID number without using its name. I need the Move scene to ask “What is my ID number”

     

    I tried the code you both sent me and to get them to work I need to ask for the scene ID by using its Name (including its version number eg Move_Lounge_3.1) which means that there is a lot of admin to do every time I update the scene to a new version.

     

    Is there a way to get the Move scene to gets its own ID number without using its name?

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