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
What makes you conclude that? Because it should work.
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
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
.
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 ?
You have to be more elaborate than just “it doesn’t work”.
What do you mean by “multiple channels”?
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);
}
Does it? Can you post a screenshot? I didn’t think that the app supported subcapabilities (it would only show the first onoff
capability).