('pin'));
        body.delete('pin');

        const r = await fetch('api/homekit', {method: 'POST', body: body});
        alert(r.ok ? 'OK' : 'ERROR: ' + await r.text());

        await reloadHomeKit();
    });

    document.getElementById('homekit-unpair').addEventListener('submit', async ev => {
        ev.preventDefault();
        const r = await fetch('api/homekit', {method: 'DELETE', body: new FormData(ev.target)});
        alert(r.ok ? 'OK' : 'ERROR: ' + await r.text());

        await reloadHomeKit(