Some how I am not getting Custom Pairing to work following the instructions by Homey:
driver.compose.json has:
"pair": [
{
"id": "manual_pairing"
}
]
and that triggers correctly pair/manual_pairing.html from the driver and it has:
Homey.emit('manual_pairing', { address: address }).then(function (result) {
console.log('Manual pairing returned:', result);
});
where address
is collected by a form input successfully. The form has a button that triggers the function where above Homey.emit is.
That calls successfully manual_pairing
handler as defined:
session.setHandler('manual_pairing', async function (data) {
try {
console.log('manual_pairing: ', data.address);
const api = new GoeChargerApi();
api.address = data.address;
const initialInfo = await api.getInitialInfo();
initialInfo.address = data.address;
console.log('manual_pairing result: ', initialInfo);
return {
name: initialInfo.name,
data: {
id: initialInfo.id,
},
settings: {
address: initialInfo.address,
},
store: {}
}
} catch (e) {
console.log(e);
throw new Error(this.homey.__('pair.error'));
}
});
as is evidenced in console I do receive the two outputs:
manual_pairing: 192.168.4.16
manual_pairing result: { id: '000000', name: 'go-eCharger 000000', address: '192.168.4.16' }
This is where I seem to fail on returning the device definition back to frontend manual_pairing.html, it should now output to console.log('Manual pairing returned:', result);
, but nothing happens.
Next I would want the returned device definition to be used to add the device as defined. But since I can’t get the thing to even respond with the result, how can I get it to do something with the result.