It's not very clear to me what it is you want to send, is it the switch's number (as in: there are multiple switch widget and you want to know which one is interacted with) or the button's number within a switch (as in: the switch sends values that are not reflecting the actual selected position and you want to send that information as well) ?
Yes, this is it !
each buttons are able to send their correct assigned value, but I want to also send the actual button's number (Button 1, Button 2, 18, etc..)
var values = getProp(this, 'values')
var n
if (Array.isArray(values)) {
// if values is written as an array (["a", "b"])
n = values.indexOf(value)
} else {
// if values is written as an object ({"label a": "a", "label b": "b"})
n = Object.values(values).indexOf(value)
}
// now do something with n
console.log('value pressed n° ' + n)
send('/switch/n', n)