# Using the same capability more than once

**URL:** <https://community.homey.app/t/using-the-same-capability-more-than-once/32264>\
**Category:** Apps\
**Tags:** app\
**Created:** [July 11, 2020, 9:32am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264 "2020-07-11T09:32:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marwan\_Magdy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marwan_magdy/32/17200_2.png) [@Marwan\_Magdy](https://community.homey.app/u/Marwan_Magdy)\
**Post date:** [July 11, 2020, 9:32am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/1 "2020-07-11T09:32:15Z")

</div>

It’s currently available to use the same capability more than once. while configuring sonoff wall switch i had to add 3 onoff capability. Couldn’t how to do it yet without adding 3 devices which pretty annoying.  
anyone has come through this  
p.s  
appending dot followed by an identifier after the capability id isn’t available anymore

---

<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 11, 2020, 9:38am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/2 "2020-07-11T09:38:49Z")

</div>

> [@Marwan\_Magdy](#):
>
> appending dot followed by an identifier after the capability id isn’t available anymore

What makes you conclude that? Because it should work.

---

<div class="post-metadata">

**Author:** ![Marwan\_Magdy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marwan_magdy/32/17200_2.png) [@Marwan\_Magdy](https://community.homey.app/u/Marwan_Magdy)\
**Post date:** [July 11, 2020, 10:48am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/3 "2020-07-11T10:48:11Z")

</div>

I couldn’t get it to work and read in a few topics that it’'s available currently

this.registerCapabilityListener([‘onoff.1’, ‘onoff.2’],  
this.onCapabilityOnoff.bind(this));

am i initializing correctly

---

<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 11, 2020, 11:02am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/4 "2020-07-11T11:02:21Z")

</div>

Make sure they are defined in `app.json`.

Also, `registerCapabilityListener` is meant for only one capability; if you want to listen on multiple capabilities (even if they have the same “base”), use [`registerMultipleCapabilityListener`](https://developer.athom.com/docs/apps/Device.html#registerMultipleCapabilityListener).

---

<div class="post-metadata">

**Author:** ![Marwan\_Magdy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marwan_magdy/32/17200_2.png) [@Marwan\_Magdy](https://community.homey.app/u/Marwan_Magdy)\
**Post date:** [July 12, 2020, 8:44am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/5 "2020-07-12T08:44:12Z")

</div>

```
    this.registerMultipleCapabilitycListenerCapabilityListener(
        ["onoff.1", "onoff.2", "onoff.3"],
    this.onCapabilityOnoff.bind(this));

```

i tried it like this and i made sure that it’s defined in app.json and in driver.compose.json  
however it doesn’t work

can i register only one onoff capability with multiple channels ?

---

<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 12, 2020, 9:04am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/6 "2020-07-12T09:04:04Z")

</div>

> [@Marwan\_Magdy](#):
>
> i tried it like this and i made sure that it’s defined in app.json and in driver.compose.json  
> however it doesn’t work

You have to be more elaborate than just “it doesn’t work”.

> [@](#):
>
> can i register only one onoff capability with multiple channels ?

What do you mean by “multiple channels”?

---

<div class="post-metadata">

**Author:** ![Marwan\_Magdy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marwan_magdy/32/17200_2.png) [@Marwan\_Magdy](https://community.homey.app/u/Marwan_Magdy)\
**Post date:** [July 12, 2020, 9:20am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/7 "2020-07-12T09:20:55Z")

</div>

it literally doesn’t work no debugging prints executed nothing  
it appears as three onoff switch in the app but none of them execute anything  
below is the onCapabilityonoff function

async onCapabilityOnoff( value, opts ){  
const devicesCache = this.getData();  
const mac = devicesCache.cash[1][“mac”];  
const arpTable = { “ip”: “10.2.100.135”, mac };  
const connection = new ewelink({ devicesCache, arpTable });  
this.log(value);  
if (value == true )  
var tog = ‘on’;  
else  
var tog = ‘off’;  
this.log(value, “tog”, tog);  
var status = await connection.setDevicePowerState(  
devicesCache.cash[0], devicesCache.cash[0][“deviceid”], tog , 3);

```
      this.log("3", status);

}
```

---

<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 12, 2020, 9:36am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/8 "2020-07-12T09:36:34Z")

</div>

> [@Marwan\_Magdy](#):
>
> it appears as three onoff switch in the app

Does it? Can you post a screenshot? I didn’t think that the app supported subcapabilities (it would only show the first `onoff` capability).

---

<div class="post-metadata">

**Author:** ![Marwan\_Magdy](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marwan_magdy/32/17200_2.png) [@Marwan\_Magdy](https://community.homey.app/u/Marwan_Magdy)\
**Post date:** [July 13, 2020, 7:47am UTC](https://community.homey.app/t/using-the-same-capability-more-than-once/32264/9 "2020-07-13T07:47:45Z")

</div>

I guess it was typo after all, it works fine now  
thanks a lot for your support

this.registerMultipleCapabilityListener(  
[“onoff.1”, “onoff.2”, “onoff.3”],  
this.onCapabilityOnoff.bind(this));

 ![Screenshot_20200713-094234_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/9/c96505e0924658c4077bcc553d756e5f0ff93669.jpeg)
