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

[HC3] Filter devices by property


Question

Posted (edited)

Hi,

I read the documentation 

Please login or register to see this link.

 and tried several approaches, but I'm unable to make filtering devices by properties working. Example code:

 

Please login or register to see this code.

 

I tried also without curly brackets, without key naming, but none worked. I attached example JSON of device I'm trying to filter. Can you please help? 

Please login or register to see this attachment.

Edited by Tazovsky
I made a typo.

9 answers to this question

Recommended Posts

  • 0
Posted

That is the old documentation, you need this one 

Please login or register to see this link.

  • 0
  • Inquirer
  • Posted
    On 11/27/2022 at 9:42 PM, pnutp0wer said:

    That is the old documentation, you need this one 

    Please login or register to see this link.

    I tried

    Please login or register to see this link.

    but it doesn't work either:

     

    Please login or register to see this code.

     

    output:

    Please login or register to see this code.

     

    • 0
    Posted

    In the P1 Monitor i get all devices with the “energy” interface to do some calculations.
     

    I do so with: 

     

    local devices, status = api.get("/devices?interface=energy")

    • 0
  • Inquirer
  • Posted
    4 hours ago, SmartHomeEddy said:

    In the P1 Monitor i get all devices with the “energy” interface to do some calculations.
     

    I do so with: 

     

    local devices, status = api.get("/devices?interface=energy")

    I'm not sure how that can solve my problem? 

    • 0
    Posted

    Eddy, can you also get multiple interface or in my case baseType

    local devices, status = api.get("/devices?baseType=com.fibaro.smokeSensor")

    i also want floodSensor

     

    thx

    • 0
    Posted
    filterBrand={enabled="true",baseType="com.fibaro.smokeSensor"}
    filterCO={enabled="true",baseType="com.fibaro.gasDetector"}
    filterCOfibaro={enabled="true",baseType="com.fibaro.coDetector"}
     
    deviceIdsBrand=_f.getDevicesID(filterBrand)
    deviceIdsCO=_f.getDevicesID(filterCO)
    deviceIdsCOfibaro=_f.getDevicesID(filterCOfibaro)
     
    how can i get this to work
     
    for k,v in ipairs(deviceIdsBrand,deviceIdsCO,deviceIdsCOfibaro) do
    print("ID ="..v)
    end
    • 0
    Posted (edited)

    @Kage i tried for many hours to get those filter to work. Multiple interface filters does not work. 

    Single filter you can do like this:

     

    {"filters": [{"filter": "type", "value": ["com.fibaro.FGR223"]}],"attributes": {}}

     

    try it out in swagger

     

    Edited by Momos
    • 0
    Posted

    try this

    filterFire={enabled="true",baseType="com.fibaro.smokeSensor"}

    filterWater={enabled="true",baseType="com.fibaro.floodSensor"}

    FilterCO={enabled="true",baseType="com.fibaro.gasDetector"}

    deviceIdFire=fibaro.getDevicesID(filterFire)

    deviceIdWater=fibaro.getDevicesID(filterWater)

    deviceIdCO=fibaro.getDevicesID(FilterCO)

     

    filter=({deviceIdFire,deviceIdWater,deviceIdCO})

    for k,v in ipairs(filter)do

      for d,b in ipairs(v)do

        print("ID = "..b.." end name ="..fibaro.getName(b))

      end

    end

     

    this works great! multiple filters

    • 0
  • Inquirer
  • Posted (edited)

    FYI,

    I figured out the solution - the key is to always pass attributes, even empty one - even if they are empty - then just add attributes = {}:

     

    Please login or register to see this code.

    Please login or register to see this code.

    or add properties value to main key if you want to have properties returned in response.

    Edited by Tazovsky

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