Custom pairing to configure device IP address

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.

Looks okay to me, and similar code is working just fine for me.

Assuming that there are no errors being thrown (you’re not dealing with those in the frontend code, but I’m pretty sure they will end up in your browser’s dev console) it might be caused by something not shown in your code snippet.

But of course, browser dev tools console, and there it is. How silly of me.
Next to figure out how to send that to the next view for user to verify the found device before adding it.

Replying to myself.

manual_pairing and add_device are now working properly with IP address configuration custom view.
Now I can go back to device.js and fix the addressing logic.

Thanks @robertklep for pointing to dev console of the browser, I had completely forgot it.

1 Like