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:
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:
{
"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?