Set homekit_exclude for all devices

I want to add Homey as a Hub in Homekit…
Homekit Hubs only support 150 Devices.
I have way more than that. I see that there is a an option to exclude specific devices from homekit. But going into hundreds of devices to set this to true are way to many clicks… is there a way to write a script or sth to set device.settings.homekit_exclude to true?

I found the solution. So I will put it here for all adventures on the same quest.

  1. You need to create an API Key in the Settings.

  2. Copy the Code to new homeyscript file.

  3. Enjoy

let token = "YOUR_TOKEN_HERE";

// URL zur Homey-API für Geräte
const devicesUrl = "";

async function updateDeviceSettings(deviceId, updatedSettings) {
    const deviceUrl = `${devicesUrl}/${deviceId}`;
    const response = await fetch(deviceUrl, {
        method: 'PUT',
        headers: {
            'Authorization': `Bearer ${token}`, 
            'Content-Type': 'application/json'
        body: JSON.stringify({ settings: updatedSettings })

    if (!response.ok) {
        throw new Error(`HTTP error when updating device (${deviceId}) settings! Status: ${response.status}`);

try {
    // Alle Geräte abrufen
    let response = await fetch(devicesUrl, {
        method: 'GET',
        headers: {
            'Authorization': `Bearer ${token}`

    if (!response.ok) {
        throw new Error(`HTTP error when fetching devices! Status: ${response.status}`);

    const allDevices = await response.json();

    for (let deviceId in allDevices) {
        const device = allDevices[deviceId];
        const updatedSettings = { ...device.settings, homekit_exclude: true };
        await updateDeviceSettings(deviceId, updatedSettings);

    return "HomeKit-Ausschluss für alle Geräte wurde erfolgreich auf 'true' gesetzt.";

} catch (error) {
    return `Error: ${error.message}`;
1 Like

Pretty sure it is possible with a small simple script in the Web API Playground,

there are a lot of examples on the community, haven’t seen this request before but maybe you get inspired by one of this,
Developer Web API Playground - Notes of geeky oneliners

or one of the many other posts.