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


Question

Posted

Hi

 

Let us assume we name a light device with the name "roof" if you have only one light device in a room. This means you have a lot of light devices with the same name in the Fibaro system, but of course different ID numbers...

 

 

Now... Let us assume I have a LUA code and handle for example light ID 144. It is easy to look up its name and present that to the user instead of the ID as its name exists in the light device JSON code through the API. But if I have more rooms it will probably be so that I will present several light IDs with the same name, as their names are the same, but in different rooms.

 

Therefor I would like to look up the lighid device number and get its name PLUS the room it is in. In this case I can present it like "Bathroom/Roof" instead of just "Roof".

 

The problem is that the light device JSON object has no info about the room it is in. and the Room JSON object has no info in it about the devices in the room.

 

 

Anyone that knows how to easily look up the room a device is in?

 

Tnx

/Peo

 

 

/Peo

5 answers to this question

Recommended Posts

  • 0
Posted

You make a reverse lookup table for the json/hometable 

 

  • 0
  • Inquirer
  • Posted

     

    I have no problem creating any object in my LUA code if I can benefit from it. I create my own JSON "work-objects" in may code bases when needed. 

     

    However....

     

    Looked a little more and saw I must have been tired :)  Getting the light device JSON object, I now see it has a "roomID" attribute on it. This means I easily can get the room ID from the light device object and then get the room name from the room ID JSON object.

     

     

     

     

    • 0
    Posted (edited)
    11 hours ago, pos said:

     

    I have no problem creating any object in my LUA code if I can benefit from it. I create my own JSON "work-objects" in may code bases when needed. 

     

    However....

     

    Looked a little more and saw I must have been tired :)  Getting the light device JSON object, I now see it has a "roomID" attribute on it. This means I easily can get the room ID from the light device object and then get the room name from the room ID JSON object.

     

     

    Hi @pos,

     

    You don't need API REST calls to get device name and room. This can be easily done with Fibaro LUA functions as in bellow example:

    Please login or register to see this code.

     

    Edited by Sankotronic
    • Like 1
    • 0
  • Inquirer
  • Posted

    @Sankotronic

     

    Many thanks. Then I can skip some LUA. Did not know that built in command existed!

     

    /Peo

    • 0
    Posted

    I sent the proposal to the fibaro for the functions:

     

    fibro: getDevicesByRoomId (roomID)
    fibaro: getDevicesByRoomIdAndType (roomID, deviceType)

    both functions return a collection of device objects, or at least an id collection

    They answered:

    Great idea, I will forward it to Our software developer team for checking the possibility of implementation.

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