# Force UI update on setting 'uiComponent: null'

**URL:** <https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679>\
**Category:** Developers\
**Created:** [February 26, 2025, 11:21pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679 "2025-02-26T23:21:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeroen\_S](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_s/32/113171_2.png) [@Jeroen\_S](https://community.homey.app/u/Jeroen_S)\
**Post date:** [February 26, 2025, 11:21pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/1 "2025-02-26T23:21:25Z")

</div>

Hi,

Is there a way to force an UI reload for a Device.

Use-Case: A certain function is disabled in the App/Device Settings and in the ‘onSettings’ the corresponding button is hidden using:

```auto
await this.setCapabilityOptions(buttonID, {
        uiComponent: null
      });

```

However when closing the Settings, the UI is not updated and the button is still shown/visible.

Is there a way to force and update (or if needed close the UI)?

 ![Schermafbeelding 2025-02-27 om 00.20.18](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/5/45217ba0aaa6a768272d36d654fc28c5205fbeac.jpeg)

---

<div class="post-metadata">

**Author:** ![Jeroen\_S](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_s/32/113171_2.png) [@Jeroen\_S](https://community.homey.app/u/Jeroen_S)\
**Post date:** [February 27, 2025, 1:15am UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/2 "2025-02-27T01:15:03Z")

</div>

To add to this it does update when you close the view (manual user interaction) and re-open it but that is not great user experience - hence the update / reload question…

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [February 28, 2025, 11:27am UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/3 "2025-02-28T11:27:47Z")

</div>

There seems to be a bug in the latest app versions as often the capabilities don’t update while the UI is open and require the user to close and open it again.

---

<div class="post-metadata">

**Author:** ![Frickadillus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/frickadillus/32/69500_2.png) [@Frickadillus](https://community.homey.app/u/Frickadillus)\
**Post date:** [March 9, 2025, 11:38am UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/4 "2025-03-09T11:38:43Z")

</div>

Hey @Jeroen_S,

Have you ever gotten this to work? I am also looking into implementing the option for the user to hide uninteresting capabilities from the app settings.

@Adrian_Rockall, do you know if this bug also apply to the Homey web app?

---

<div class="post-metadata">

**Author:** ![Jeroen\_S](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_s/32/113171_2.png) [@Jeroen\_S](https://community.homey.app/u/Jeroen_S)\
**Post date:** [March 9, 2025, 12:09pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/5 "2025-03-09T12:09:43Z")

</div>

Not really just took on it was a bug.

For me not a real issue because it only happens when you change the settings and when you close the view and open it again it then it is okay - until you change settings again, but that hardly ever happens.

Do you need to do it on the fly?

---

<div class="post-metadata">

**Author:** ![Frickadillus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/frickadillus/32/69500_2.png) [@Frickadillus](https://community.homey.app/u/Frickadillus)\
**Post date:** [March 9, 2025, 1:14pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/6 "2025-03-09T13:14:27Z")

</div>

I’m trying to hide certain capabilities (sensors) from the app’s GUI based on user settings. However, I’m having trouble getting the sensors to hide as expected.

Here’s the relevant part of my `device.js` file where I set the `uiComponent` in the `onSettings` method:

```auto
async onSettings({ oldSettings, newSettings, changedKeys }) {
  this.log('Settings changed:', { oldSettings, newSettings, changedKeys });

  for (const key of changedKeys) {
    switch (key) {
      default:
        if (key.includes('pump')) {
          await this.setCapabilityOptions(key, {
            uiComponent: newSettings[key] ? 'sensor' : null
          });
        }
        break;
    }
  }
}

```

And here’s the relevant part of my `driver.compose.json` file:

```auto
{
  "type": "group",
  "label": { "en": "Show/Hide Sensors" },
  "children": [
    {
      "id": "pump1",
      "type": "checkbox",
      "label": { "en": "Show Pump 1" },
      "value": true
    },
    {
      "id": "pump2",
      "type": "checkbox",
      "label": { "en": "Show Pump 2" },
      "value": true
    },
    {
      "id": "pump3",
      "type": "checkbox",
      "label": { "en": "Show Pump 3" },
      "value": true
    },
    {
      "id": "pump4",
      "type": "checkbox",
      "label": { "en": "Show Pump 4" },
      "value": true
    },
    {
      "id": "pump5",
      "type": "checkbox",
      "label": { "en": "Show Pump 5" },
      "value": true
    },
    {
      "id": "pump6",
      "type": "checkbox",
      "label": { "en": "Show Pump 6" },
      "value": true
    }
  ]
}

```

I have tried restarting the app after setting e.g. pump1 to false, but the sensor is still visible in the UI. Any suggestions?

---

<div class="post-metadata">

**Author:** ![Jeroen\_S](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_s/32/113171_2.png) [@Jeroen\_S](https://community.homey.app/u/Jeroen_S)\
**Post date:** [March 9, 2025, 3:46pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/7 "2025-03-09T15:46:57Z")

</div>

Mine is not that different I call an update function:

```auto
  async updateUIButtons(buttonID, buttonEnable) {
    this.writeLog(`Updating UI Button: ${buttonID}, Enabled: ${buttonEnable}`);

    if (buttonEnable) {
      await this.setCapabilityOptions(buttonID, { uiComponent: "button" });
    } else {
      await this.setCapabilityOptions(buttonID, { uiComponent: null });
    }
  }

```

Do you change the settings through the settings menu or programmatically? (the latter does not trigger the onSettings?). Also if you log the key value is it the right object?

---

<div class="post-metadata">

**Author:** ![Frickadillus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/frickadillus/32/69500_2.png) [@Frickadillus](https://community.homey.app/u/Frickadillus)\
**Post date:** [March 19, 2025, 1:47pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/8 "2025-03-19T13:47:50Z")

</div>

Thanks @Jeroen_S,

I tried your code to set uiComponent to null for an enum sensor, but it remain visible at all time in the UI.

 ![sensors](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/f/8fece83beb226fc417aa737d174500b262aec9de.png)

Here is the relevant code that I use:

```auto
this.updateUISensors("pump1", false); //Calling the function to show or hide capabilities

  async updateUISensors(sensorId, Enable) {
    this.log(`Updating UI Button: ${sensorId}, Enabled: ${Enable}`);

    if (Enable) {
      await this.setCapabilityOptions(sensorId, { uiComponent: "enum" });
    } else {
      await this.setCapabilityOptions(sensorId, { uiComponent: null });
    }
  }

```

```auto
pump1.json:
{
  "type": "enum",
  "title": {
    "en": "Pump 1"
  },
  "values": [
    {
      "id": "off",
      "title": {
        "en": "Off"
      }
    },
    {
      "id": "low",
      "title": {
        "en": "Low"
      }
    },
    {
      "id": "high",
      "title": {
        "en": "High"
      }
    }
  ],
  "uiComponent": "sensor",
  "icon": "assets/icons/pumpMode.svg",
  "getable": true,
  "setable": false
}

```

Any thoghts? Thx!

---

<div class="post-metadata">

**Author:** ![Jeroen\_S](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeroen_s/32/113171_2.png) [@Jeroen\_S](https://community.homey.app/u/Jeroen_S)\
**Post date:** [March 23, 2025, 2:52pm UTC](https://community.homey.app/t/force-ui-update-on-setting-uicomponent-null/131679/9 "2025-03-23T14:52:19Z")

</div>

Can you post the Log output?
