# Homeyduino: setCapabilityValue does not change Homey state?

**URL:** <https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191>\
**Category:** Developers\
**Created:** [July 8, 2020, 10:31pm UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191 "2020-07-08T22:31:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [July 8, 2020, 10:31pm UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/1 "2020-07-08T22:31:13Z")

</div>

Hi, I have a simple homeyduino project. And I want to change a capability state in Homey. But Homey does not change the state.

In the setup I have:  
`Homey.addCapability("onoff", AlarmOnOff);`  
And this works fine to trigger the arduino.

But when I try to set the capablility inside Arduino and want to change the state in Homey, noting happens.  
I tried:  
`Homey.setCapabilityValue("onoff", false);`  
or  
`Homey.setCapabilityValue("onoff", 0);`  
or  
`Homey.setCapabilityValue("onoff", "0");`  
None of them seem to change the state of the tile. What am I missing?

---

<div class="post-metadata">

**Author:** ![rindler](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rindler/32/5501_2.png) [@rindler](https://community.homey.app/u/rindler)\
**Post date:** [July 9, 2020, 4:53am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/2 "2020-07-09T04:53:05Z")

</div>

`Homey.setCapabilityValue(“alarm_smoke”, (bool) false);` works for me.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 9, 2020, 4:58am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/3 "2020-07-09T04:58:30Z")

</div>

Are you calling `Homey.loop()` from inside the `loop()` method? Have you called `setClass()`?

---

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [July 9, 2020, 8:21am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/4 "2020-07-09T08:21:46Z")

</div>

> [@robertklep](#):
>
> Are you calling `Homey.loop()`

Yes (otherwise control from Homey would not work either)

> [@robertklep](#):
>
> Have you called `setClass()` ?

No, is this mandatory? According to the usage guide it defaults to “other”:

> [@](#):
>
> If your device is of a certain class then you can set the class by calling `Homey.setClass("<class>");` from within `setup()` . By default the class is set to “other”, which means that none of the special features that certain classes provide are enabled.

I’ll set the setclass and report if it makes a difference.

> [@rindler](#):
>
> `Homey.setCapabilityValue(“alarm_smoke”, (bool) false);` works for me.

I shall try this syntax. Maybe “onoff” isn’t settable? (according to the documentation it is).

---

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [July 9, 2020, 8:30am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/5 "2020-07-09T08:30:50Z")

</div>

> [@Satoer](#):
>
> > [@robertklep](#):
> >
> > Have you called `setClass()` ?
> 
> No, is this mandatory? According to the usage guide it defaults to “other”:

Well… it turns out it is. if I add:  
`Homey.setClass("socket");`  
it works…  
But also when I change it to:  
`Homey.setClass("other");`  
So it does not default to `other` even when the documentation stated this. 🙄

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 9, 2020, 8:34am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/6 "2020-07-09T08:34:43Z")

</div>

> [@Satoer](#):
>
> So it does not default to `other` even when the documentation stated this

Looking at the code, it does.

---

<div class="post-metadata">

**Author:** ![Satoer](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/satoer/32/38113_2.png) [@Satoer](https://community.homey.app/u/Satoer)\
**Post date:** [July 9, 2020, 8:45am UTC](https://community.homey.app/t/homeyduino-setcapabilityvalue-does-not-change-homey-state/32191/7 "2020-07-09T08:45:07Z")

</div>

Then I think it’s some kind of capability caching inside homey even though I removed the device and re-add it. (I did not change the name of the device). If I block out the setclass instruction (basically the old code again) it keeps on working… weird. Ill keep it to “socket” just to be safe.
