---
title: "Glofox room bookings — room preparation"
description: "Prenotazioni sale Glofox via API cloud, un modulo per sala: Booked now, Minutes to next booking, Prepare room per scaldare e illuminare in anticipo."
url: "https://taphome.com/it/compatibility/glofox-room-bookings-http/"
language: it
lastmod: 2026-11-10
generator: hugo
ai:
  topics: ["http","cloud-api","rest-api","sensor","room-booking","facility-booking","scheduling","occupancy","fitness-studio"]
  questions: ["Come integrare le prenotazioni delle sale Glofox con TapHome?","Cosa legge il modello TapHome per le prenotazioni delle sale Glofox?","Come richiedere l'accesso all'API Glofox per TapHome nell'ABC Fitness Developer Portal?","Come trovare il Glofox Branch ID e il fuso orario dello studio?","Come rendere una sala una facility prenotabile in Glofox?","Come trovare il Facility ID di una sala Glofox?","Come riscaldare una sala e accendere le luci prima di una prenotazione Glofox?","Perché i valori della sala Glofox in TapHome sono sfasati di un'ora?"]
---

# Glofox room bookings — room preparation

Comunicazione: Packet Parser → HTTP

## Guida all'integrazione

Glofox è una piattaforma di prenotazione cloud di ABC Fitness, quindi non c'è nulla da cablare: l'unità di controllo Core di TapHome legge le prenotazioni delle sale dalla REST API di Glofox tramite HTTPS. La configurazione lato studio ha tre parti: l'accesso all'API Glofox per lo studio, ogni sala in affitto configurata come facility prenotabile, e il Branch ID e il fuso orario dello studio. Il modello si importa poi una volta per ogni sala.

Gli screenshot provengono da una location di test Glofox Sandbox (ABC Fitness Developer Portal e dashboard Glofox, ottobre 2026) e dall'app TapHome collegata a un'unità di controllo di test con prenotazioni simulate.

## Configurazione

### 1. Richiedi l'accesso all'API Glofox

Il **superadmin** dello studio si registra nell'[ABC Fitness Developer Portal](https://api-portal.glofox.com/api-portal/#/glofox/request-access) (Account Type *Customer*) e fa clic su **Request Integrator**:

- **Environment:** *Live* (*Sandbox* è solo una location di test con dati demo).
- **Namespace:** il namespace Glofox dello studio.
- **Intended Use Case:** ad esempio "TapHome building automation reads facility bookings to prepare rooms (heating, lights, audio) before each booking. Read-only."

ABC Fitness esamina le richieste Live e risponde via e-mail. La **chiave API** e il **token API** si richiedono poi con **Request credentials** e arrivano all'indirizzo e-mail del portale. Domande sull'accesso: glofox.apisupport@abcfitness.com.

![Guida alla richiesta di accesso nell'ABC Fitness Developer Portal](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-request-access_hu_ad9d259835295a2f.jpg)

> [!WARNING]
> La chiave API e il token API danno accesso ai dati Glofox dello studio. Glofox chiede di usarli solo in integrazioni backend, mai in applicazioni lato client; in TapHome vanno inseriti solo nei parametri di importazione del modello.

### 2. Rendi ogni sala una facility prenotabile

Per prima cosa attiva **Settings → Booking → Facility Rental**; solo dopo compaiono gli interruttori delle facility descritti sotto. Poi **Manage → Facilities** elenca le sale. Ogni sala che i trainer affittano deve essere una facility con **Bookable** attivo, un calendario di slot (scheda *Schedule*) e, in *Price / Eligibility*, *Drop In Clients* o *Clients* consentiti (un prezzo pari a 0 va bene). Senza queste impostazioni la prenotazione del trainer termina con "Membership not allowed".

![Facilities nella dashboard Glofox](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-facilities_hu_1f8fd4b2268aac05.jpg)

![Dettaglio della facility con Public e Bookable attivi](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-facility-bookable_hu_e15ed6a0933935cc.jpg)

### 3. Trova il Branch ID e il fuso orario dello studio

Con la chiave API e il token, una sola richiesta restituisce la location dello studio, il suo ID e il suo fuso orario:

```bash
curl -s -X POST https://gf-api.aws.glofox.com/prod/v3.0/locations/retrieve \
  -H "x-api-key: <API key>" -H "x-glofox-api-token: <API token>" \
  -H "Content-Type: application/json" -d '{}'
```

`data[]._id` è il **BranchId**, `data[].address.timezone_id` il fuso orario dello studio (ad esempio `Europe/Rome`). Senza filtro la richiesta restituisce tutte le location nei namespace che l'integrazione può leggere, quindi con più studi scegli la voce dello studio di cui i moduli controllano le sale.

L'orologio degli script dell'unità di controllo Core deve essere nel fuso orario dello studio: su Core 2025.2 è il fuso orario di sistema dell'unità di controllo, sulle versioni più recenti di Core il fuso orario del luogo (location) TapHome.

### 4. Importa il modello una volta per ogni sala

Nell'app TapHome apri l'interfaccia **Packet Parser** (se l'unità di controllo non ne ha una, aggiungila prima), poi **Aggiungi dal modello → Aggiungi da file** e scegli il modello scaricato. Compila `ApiKey`, `ApiToken`, `BranchId`, `LeadMinutes` e il `FacilityId` della sala.

Inserisci il nome della sala in **Prefisso del nome del dispositivo** e terminalo con un separatore, ad esempio `Sala yoga - `. Il prefisso viene unito ai nomi dei dispositivi esattamente come lo digiti, quindi senza separatore un dispositivo si chiama "Sala yogaBooked now". **Zona** colloca i tre dispositivi della sala nella zona della sala.

![Parametri di importazione nell'app TapHome](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-app-import_hu_5455f063da370ee.jpg)

Se non conosci ancora il Facility ID, inserisci un testo qualsiasi. Dopo la prima interrogazione il modulo segnala un errore che elenca tutte le facility della sede con il loro ID (**Dispositivi → Errori e avvisi** → il modulo):

![Errore del modulo con l'elenco delle facility della sede](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-app-error_hu_e4c5cc3bd4339a45.jpg)

Copia l'ID corretto nella variabile `FacilityId` del modulo (oppure importa di nuovo il modello) e ripeti per ogni sala.

### 5. Verifica con il calendario Glofox

Le prenotazioni di una sala compaiono nel **Calendar** di Glofox (filtro *Facilities*). Con una prenotazione dalle 10:00 alle 11:00 e `LeadMinutes` 60, i valori della sala sono:

| Ora | Booked now | Minutes to next booking | Prepare room |
|---|---|---|---|
| 8:30 | Free | 90 | Idle |
| 9:00 | Free | 60 | Prepare |
| 10:30 | Booked | prossima prenotazione o 1440 | Prepare |
| 11:00 | Free | prossima prenotazione o 1440 | Idle |

I minuti sono minuti interi contati dall'interrogazione, quindi un valore può differire di uno dalla tabella.

![Prenotazione della facility nel calendario Glofox](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-calendar_hu_3b3e02e5fd126f55.jpg)

Nell'app TapHome ogni sala mostra i tre valori sotto il proprio modulo:

![Valori della sala nell'app TapHome](https://taphome.com/images/compatibility/glofox-room-bookings-http/glofox-app-devices_hu_e3c9e82eae9fa28e.jpg)

## Smart rule

**Prepare room** (preparazione della sala) è la condizione delle smart rule della sala: setpoint di riscaldamento o raffrescamento, luci e scena audio finché è *Prepare*, tutto spento quando torna a *Idle*. **Booked now** (sala prenotata ora) è adatto ai display di occupazione; **Minutes to next booking** (minuti alla prossima prenotazione) permette a una smart rule di avviare un impianto di riscaldamento lento con più anticipo di `LeadMinutes`.

## Dispositivi disponibili 3

Questi dispositivi compaiono in TapHome dopo l'importazione.

Glofox Room Modulo

Lettura (modulo)

```taphome
# Bookings of this room (FacilityId) that run now or start within 24 h. Glofox times are the studio's local time
# ("yyyy-MM-dd HH:mm:ss"), so the Core's time zone must be the studio's. Texts in that format sort like the times,
# which lets JSONPath filters compare them directly.
VAR now := NOW();
VAR nowText := TOSTRING(now, "yyyy-MM-dd HH:mm:ss");
VAR leadText := TOSTRING(DATETIMEADD(now, 0, 0, 0, 0, LeadMinutes), "yyyy-MM-dd HH:mm:ss");
VAR nowLocal := ROUND(now.UNIXTIME + LOCALTIMEZONE() / 1000);
VAR hKey := "x-api-key: " + ApiKey;
VAR hToken := "x-glofox-api-token: " + ApiToken;
VAR hBranch := "x-glofox-branch-id: " + BranchId;
VAR msg := "";
VAR i := 0;
VAR fid := "";

# Every failed poll ends in RETURN before the values are written. After five failed polls in a row (Glofox or the
# internet down) the room is released, so an old "Prepare" does not keep heating and lights on.
failCount := failCount + 1;
IF failCount > 5
    bookedNow := 0;
    prepareRoom := 0;
    minsToNext := 1440;
END

# After start and then once an hour: the configured room must exist; if not, the error lists the rooms of the branch
# with their ids. facilityCheck counts the polls until the next check.
IF facilityCheck <= 0
    VAR fresp := SENDHTTPREQUEST("/prod/3.0/locations/" + BranchId + "/facilities?limit=100", "GET", "", hKey, hToken, hBranch);
    IF !fresp.IsSuccess
        # no connection: StatusCode 0 and no ReasonPhrase
        IF !ISNULL(fresp.ReasonPhrase)
            msg := " " + fresp.ReasonPhrase;
        END
        ADDERROR(1, "Glofox API: HTTP " + TOSTRING(fresp.StatusCode, "F0") + msg);
        RETURN(0);
    END
    IF ISNULL(PARSEJSON(fresp.Content, "$.data", TRUE))
        msg := PARSEJSON(fresp.Content, "$.message", TRUE);
        ADDERROR(2, "Glofox API: " + IF(ISNULL(msg), "unexpected answer", msg));
        RETURN(0);
    END
    IF ISNULL(PARSEJSON(fresp.Content, "$.data[?(@._id == '" + FacilityId + "')].name", TRUE))
        msg := "";
        fid := PARSEJSON(fresp.Content, "$.data[0]._id", TRUE);
        WHILE !ISNULL(fid)
            msg := msg + IF(i = 0, ": ", "; ") + PARSEJSON(fresp.Content, "$.data[" + TOSTRING(i, "F0") + "].name", TRUE) + " = " + fid;
            i := i + 1;
            fid := PARSEJSON(fresp.Content, "$.data[" + TOSTRING(i, "F0") + "]._id", TRUE);
        LOOP
        ADDERROR(3, "Facility '" + FacilityId + "' is not in this branch. Facilities" + msg);
        RETURN(0);
    END
    facilityCheck := 60;
END
facilityCheck := facilityCheck - 1;

VAR path := "/prod/2.2/branches/" + BranchId + "/bookings?status=BOOKED&limit=50&time_finish_start_date=" + TOSTRING(nowLocal, "F0") + "&time_start_end_date=" + TOSTRING(nowLocal + 86400, "F0") + "&page=";
VAR room := "$.data[?(@.model_id == '" + FacilityId + "' && @.status == 'BOOKED' && ";
VAR newBooked := 0;
VAR newPrepare := 0;
VAR nextText := "";
VAR candidate := "";
VAR total := 0;
VAR page := 1;
VAR pages := 1;
VAR nextStart := now;

# limit=50: a booking is about 1 kB (0.9 kB measured) and SENDHTTPREQUEST accepts at most 128 kB; at most 10 pages =
# 500 bookings of the whole branch (class bookings included)
VAR resp := SENDHTTPREQUEST(path + "1", "GET", "", hKey, hToken, hBranch);
WHILE page <= pages
    IF page > 1
        resp := SENDHTTPREQUEST(path + TOSTRING(page, "F0"), "GET", "", hKey, hToken, hBranch);
    END
    IF !resp.IsSuccess
        IF !ISNULL(resp.ReasonPhrase)
            msg := " " + resp.ReasonPhrase;
        END
        ADDERROR(1, "Glofox API: HTTP " + TOSTRING(resp.StatusCode, "F0") + msg);
        RETURN(0);
    END
    # a wrong API token or BranchId answers HTTP 200 with success:false and a message, and no meta
    total := PARSEJSON(resp.Content, "$.meta.totalCount", TRUE);
    IF ISNULL(total)
        msg := PARSEJSON(resp.Content, "$.message", TRUE);
        ADDERROR(2, "Glofox API: " + IF(ISNULL(msg), "unexpected answer", msg));
        RETURN(0);
    END
    pages := MIN(10, CEIL(total / 50));
    IF !ISNULL(PARSEJSON(resp.Content, room + "@.time_start <= '" + nowText + "' && @.time_finish > '" + nowText + "')]._id", TRUE))
        newBooked := 1;
    END
    IF !ISNULL(PARSEJSON(resp.Content, room + "@.time_start <= '" + leadText + "' && @.time_finish > '" + nowText + "')]._id", TRUE))
        newPrepare := 1;
    END
    # earliest booking that has not started: take any later than now, then ask for an earlier one until none is left
    candidate := PARSEJSON(resp.Content, room + "@.time_start > '" + nowText + "'" + IF(nextText = "", "", " && @.time_start < '" + nextText + "'") + ")].time_start", TRUE);
    WHILE !ISNULL(candidate)
        nextText := candidate;
        candidate := PARSEJSON(resp.Content, room + "@.time_start > '" + nowText + "' && @.time_start < '" + nextText + "')].time_start", TRUE);
    LOOP
    page := page + 1;
LOOP
IF total > 500
    ADDWARNING(4, "More than 500 bookings of the branch in the next 24 hours; only the first 500 were read, a booking of this room beyond them is not seen");
END

failCount := 0;
bookedNow := newBooked;
prepareRoom := newPrepare;
IF nextText = ""
    minsToNext := 1440;
ELSE
    nextStart := DATETIME(nextText, "yyyy-MM-dd HH:mm:ss");
    minsToNext := MIN(1440, FLOOR((nextStart.TICKS - now.TICKS) / 60000));
END
```

Booked now Contatto reed

Lettura

```taphome
RETURN(bookedNow);
```

Minutes to next booking Variabile

Lettura

```taphome
RETURN(minsToNext);
```

Prepare room Contatto reed

Lettura

```taphome
RETURN(prepareRoom);
```

**Connessione:** Packet Parser → HTTP

## Parametri di importazione

Inserisci questi valori quando importi l'XML.

| Richiesto nell'app                                                               | Predefinito                  |
|----------------------------------------------------------------------------------|------------------------------|
| Glofox API key (x-api-key header)                                                | Da inserire all'importazione |
| Glofox API token (x-glofox-api-token header)                                     | Da inserire all'importazione |
| Glofox Branch ID (x-glofox-branch-id header)                                     | Da inserire all'importazione |
| Glofox Facility ID for this room (model\_id in booking response)                 | Da inserire all'importazione |
| Lead time in minutes — Prepare Room activates this many minutes before a booking | `60`                         |

## Documentazione correlata

- [Integrazione Packet Parser](https://taphome.com/it/compatibility/packet-parser-guide/)
- [Packet Parser (HTTP, TCP, UDP, FTP, MQTT)](https://taphome.com/it/docs/integration/packet-parser/)
- [Funzioni Packet parser](https://taphome.com/it/docs/script/packet-parser/)
- [Funzioni di parsing](https://taphome.com/it/docs/script/parsing-functions/)

