# Filtering a config object within a node that uses it

**URL:** https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357
**Category:** Developing Nodes
**Created:** [20 February 2021 17:55 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357 "2021-02-20T17:55:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Achronite](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achronite/32/31868_2.png) [@Achronite](https://discourse.nodered.org/u/Achronite)
#### Post date: [20 February 2021 17:56 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357/1 "2021-02-20T17:56:00Z")

</div>

I have a config object that is used to store/select a list of different types of IoT devices. I also have a set of specific nodes for each type of IoT device

I would like to know, is it possible to filter the devices dropdown to only shows the devices that have a productId that is specific to the node that use it. This is to prevent the user selecting the wrong device type within the configuration of a particular node type.

e.g: openThings-pir.html contains:

```auto
<script type="text/javascript">
    RED.nodes.registerType('openThings-pir', {
        category: 'Energenie 314RT',
        color: '#de348c',
        defaults: {
            name: { value: "Motion Sensor" },
            device: { type: "openThings-device", required: true },
...

```

And openThings-device.html contains:

```auto
<script type="text/javascript">
    RED.nodes.registerType('openThings-device', {
        category: 'config',
        defaults: {
            name: { value: "MiHome Device" },
            productId: { required: true },
            product: { value: "Select device from dropdown", required: false },
            deviceId: { required: true },
            control: { value: "Unknown", required: false }
        },

```

e.g. in my pir node I want to do is only display PIR devices in the dropdown (ie. ones that have a node-config-input-device-productId == 12 ). In my switch socket node i only want switch sockets, etc...

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [20 February 2021 21:58 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357/2 "2021-02-20T21:58:17Z")

</div>

Hi @Achronite,  
If I'm not mistaken the node-\>configNode link is a many-to-1 relation. So a node can have 1 config node, but a single config node can be shared across multiple nodes. If I am correct, that would be a problem for your setup?  
I have always thought that a node can get access to a config node, but not the other way around (since it can be shared between multiple nodes). But I can be mistaken...  
Bart

---

<div class="post-metadata">

### Author: ![Achronite](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/achronite/32/31868_2.png) [@Achronite](https://discourse.nodered.org/u/Achronite)
#### Post date: [21 February 2021 10:20 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357/3 "2021-02-21T10:20:32Z")

</div>

Hi @BartButenaers I don't believe that I am trying to do anything unusual in selecting which config applies to the node. I just want the list of configs to be filtered first, so that only the config items that apply can be selected from the dropdown. So in the example below I don't want the option to select the Motion Sensor, I only want the Radiator Valves to be shown.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1ae2dfec2f4f935113911a7ee83171f9d53ba65b.png)

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [21 February 2021 10:25 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357/4 "2021-02-21T10:25:07Z")

</div>

Hi,

As it stands, there's no way to filter that list.

But I can see the value in being able to do so. Have added an item to the backlog for this.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 April 2021 10:26 UTC](https://discourse.nodered.org/t/filtering-a-config-object-within-a-node-that-uses-it/41357/5 "2021-04-22T10:26:02Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
