# Is it possible to disable a capability ui-component?

**URL:** <https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981>\
**Category:** Developers\
**Created:** [November 10, 2022, 9:10am UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981 "2022-11-10T09:10:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_LABLAINE](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nicolas_lablaine/32/29951_2.png) [@Nicolas\_LABLAINE](https://community.homey.app/u/Nicolas_LABLAINE)\
**Post date:** [November 10, 2022, 9:10am UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981/1 "2022-11-10T09:10:25Z")

</div>

I am creating a driver/device for a thermostat, this one has the possibility of being locked, so that children do not modify the settings.

Is it possible to lock the user interface, gray it out, while retaining the ability to display the target and current temperature?  
Thanks

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [November 12, 2022, 8:06am UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981/2 "2022-11-12T08:06:55Z")

</div>

No, but you can manipulate it by switching the value back when its set through the UI.  
See the Device capability app sourcecode on bitbucket and look for the disabled button.

Make sure to use a timeout within the trigger Runlistener to switch the value back, the RunLisyener must be compelted before you can switch the value back.

Edit, also, it might work to override the capabilityOptions and set Setable:false.  
Not sure if that will work, but it might be worth a try.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [November 12, 2022, 8:40am UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981/3 "2022-11-12T08:40:18Z")

</div>

Okay, my answer “No” was to fast:  
Add this to your json.app:

```auto
"capabilities": {
    "target_temperature":{"value":20,"type":"number","getable":true,"setable":false,"title":"Room 1 Temperature","units":"°C","decimals":2,"min":4,"max":35,"chartType":"stepLine", "uiComponent":"thermostat"}
}

```

If you do this, you will get a warning when you try to change it:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/9/9963dd98c8adb232c95bb5194ab35e31c57bec4b.png)

So, you can do this the ‘normal’ way.

But what you also can do is how i do it with Device Capabilities’ AVDs.  
I just set that value back within the RunListener:

```auto
if (settings[fieldId + 'Disabled'] !== true) 
	this.registerCapabilityListener(cap, (async (value, options) => {					
		let oldValue = this.getStoreValue(fieldId+"Value");				
		let val = this.getStoreValue(fieldId + "Value") === true;
		return setTimeout(async () => {
			await this.setCapabilityValue(cap, val);						
		}, 1);

```

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [November 12, 2022, 8:44am UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981/4 "2022-11-12T08:44:44Z")

</div>

And, btw, fyi:  
I will be implementing a Disable function for my Advanced Virtual Devices’ Thermostats.  
So perhaps those are an option for you.

And, many thanks for giving me a great new idea:  
I will implement a feature in DC’s AVDs so you can use the thermostat as a **combination-dial** : put in the right numbers to activate a flow (and perhaps enable the normal funtions of the thermostat)!  
And turn the dial to the end/configurable-number/combination-of-numbers, and it locks again 🙂

---

<div class="post-metadata">

**Author:** ![Nicolas\_LABLAINE](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nicolas_lablaine/32/29951_2.png) [@Nicolas\_LABLAINE](https://community.homey.app/u/Nicolas_LABLAINE)\
**Post date:** [November 12, 2022, 5:25pm UTC](https://community.homey.app/t/is-it-possible-to-disable-a-capability-ui-component/71981/5 "2022-11-12T17:25:52Z")

</div>

Ok thank you, I will test!  
Glad to have participated
