# SDK question regarding setDeviceCapabilities

**URL:** <https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904>\
**Category:** Questions & Help\
**Created:** [August 12, 2023, 7:52pm UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904 "2023-08-12T19:52:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [August 12, 2023, 7:52pm UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904/1 "2023-08-12T19:52:04Z")

</div>

Apologies for a perhaps dump question (still very limited in knowledge about homey sdk and java scripting), but the here’s something I can’t get to work.

I am using the 433mhz example from the SDK pages, and got it working to receive a signal. However what I would like to do is upon receiving the signal, setting the device capability to on or off,

So in my device.js is the following;

```auto
mySignal.on("payload", function (payload, first) {
  console.log("Signal received")
  this.setCapabilityValue('onoff', false).catch(MyDevice.error);
});

```

and produces the following error:

```auto
Signal received
[HomeyClient] homey:manager:rf.onEvent Listener Error: TypeError: this.setCapabilityValue is not a function
    at Signal433.<anonymous> (/app/drivers/test/device.js:81:16)
    at Signal433.emit (node:events:525:35)
    at ManagerRF._onEvent (/node_modules/@athombv/homey-apps-sdk-v3/manager/rf.js:39:24)
    at /node_modules/@athombv/homey-apps-sdk-v3/lib/HomeyClient.js:111:13
    at Array.forEach (<anonymous>)
    at HomeyClient._onMessage (/node_modules/@athombv/homey-apps-sdk-v3/lib/HomeyClient.js:109:19)
    at EventEmitter.emit (node:events:513:28)
    at /homey-app-runner/lib/App.js:157:26
    at new Promise (<anonymous>)
    at /homey-app-runner/lib/App.js:156:18

```

How would it be possible to access the `setDeviceCapability` in that function?

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [August 12, 2023, 9:54pm UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904/2 "2023-08-12T21:54:41Z")

</div>

Change `function (payload, first)` to `(payload, first) =>` your `this` scope it not bound to the surrounding scope. When using an arrow function the` this` is bound to scope it was defined in.

---

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [August 13, 2023, 11:54am UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904/3 "2023-08-13T11:54:43Z")

</div>

Many thanks for this!

To extend the question a bit more; a similar error is given when you try to access the capabilities from the `app.js` How would you deal with this outside its own device class? i.e if I would like to check a device state in the `app.js` ?

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [August 13, 2023, 12:03pm UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904/4 "2023-08-13T12:03:14Z")

</div>

```auto
this.homey.drivers.getDriver('someid').getDevice(deviceData)

```

or

```auto
this.homey.drivers.getDriver('someid').getDevices()

```

and find the device.

---

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [August 13, 2023, 12:22pm UTC](https://community.homey.app/t/sdk-question-regarding-setdevicecapabilities/86904/5 "2023-08-13T12:22:43Z")

</div>

Much appreciated!
