# Vraag registerCapabilityListener afzonderlijk per device

**URL:** <https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556>\
**Category:** Vragen & hulp\
**Tags:** app, tools, devices\
**Created:** [July 19, 2021, 10:02am UTC](https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556 "2021-07-19T10:02:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jens\_De\_Smet](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jens_de_smet/32/33978_2.png) [@Jens\_De\_Smet](https://community.homey.app/u/Jens_De_Smet)\
**Post date:** [July 19, 2021, 10:02am UTC](https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556/1 "2021-07-19T10:02:16Z")

</div>

Beste,

Ik wil graag een `Capability Listener` die voor één apparaat afzonderlijk werkt en niet voor heel de driver.

Ik heb ook al elk aparaat een `id` gegeven.

Het zijn ook allemaal virtuele apparaten dus geen gedoe met verbinden nodig.

Heb ook al eens gekeken naar andere topic’s, maar er zijn er nog geen met dit probleem.

Graag wil ik een code voorbeeld van een `registerCapabilityListener`.

Met vriendelijke groeten,  
Jens De Smet 😀

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 20, 2021, 6:55pm UTC](https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556/2 "2021-07-20T18:55:02Z")

</div>

Misschien een startpunt:

```auto
const Homey = require("homey");

class Device extends Homey.Device {
  // this method is called when the Device is inited
  async onInit() {
    this.log("Device init");
    this.log("Name:", this.getName());
    this.log("Class:", this.getClass());

    // register a capability listener
    this.registerCapabilityListener("onoff", this.onCapabilityOnoff.bind(this));
  }

  // this method is called when the Device has requested a state change (turned on or off)
  async onCapabilityOnoff(value, opts) {
    // ... set value to real device, e.g.
    // await setMyDeviceState({ on: value });
    // or, throw an error
    // throw new Error('Switching the device failed!');
  }
}

module.exports = Device;

```

Ik heb het idee dat hier veel te vinden is voor je:

> **[Drivers and Devices](https://apps.developer.homey.app/the-basics/devices)**
>
> In Homey Apps the Device classes represent the physical devices paired with Homey.

_ik heb hier geen verstand van, maar ok gebruik gewoon een zoekmachine 🙃_

---

<div class="post-metadata">

**Author:** ![Jens\_De\_Smet](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jens_de_smet/32/33978_2.png) [@Jens\_De\_Smet](https://community.homey.app/u/Jens_De_Smet)\
**Post date:** [July 20, 2021, 7:42pm UTC](https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556/3 "2021-07-20T19:42:37Z")

</div>

Hier ben ik niet echt veel mee maar toch bedankt

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [June 9, 2025, 11:03am UTC](https://community.homey.app/t/vraag-registercapabilitylistener-afzonderlijk-per-device/49556/4 "2025-06-09T11:03:57Z")

</div>

Archived on June 9, 2025, 11:03am UTC


