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

API for categories


Kage

Question

I tryied now for 2 days en read the whole internet but with no luck.

 

So the question is

how get i;

result = api.get("/devices?{properties={categories='[\"lights\",\"security\"]'}},")

tryied everything from properties to property with { en whitout {

 

please help

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Generally there is no easy way to filter devices from API when property is an array or an object, but - as example:

Method POST /devices/filters
Body

Please login or register to see this code.


This will response with devices data (name, id and categories property) where categories are set to "lights" and "security". 

Of course you can always pull whole /api/devices and parse it yourself in the code.

Regards,
Michał 

Link to comment
Share on other sites

  • 0
22 hours ago, m.roszak said:

Of course you can always pull whole /api/devices and parse it yourself in the code.

 

I think you can parse it faster but this is a start:

Please login or register to see this code.

 

If you want to get only the lights: 

Please login or register to see this code.

See: 

Please login or register to see this link.

Edited by Joep
Typo
Link to comment
Share on other sites

  • 0

With a jsonpath library like

Please login or register to see this link.

, the below would work

Please login or register to see this code.


 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • @JoepThx for the piece. Also to jgab

     

    for now i use ;

    local result=fibaro.getDevicesID({roomID=rId,properties={categories='[\"lights\"]'}})

    but i try two things. first is create a script with zero ID specific and only specific categories or more. zo when you put a light into a room it automatically sees by the script, no editing needed.

    trying to see the differents between api and get. This in cpu clock and cpu consumption. 

     

    if someone can explain woud be nice 😃

     

     

     

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