TapHome
Community Beta Sensori

Glofox room bookings — room preparation

Prenotazioni delle sale Glofox (facility) in TapHome tramite la REST API cloud di Glofox (HTTPS), un modulo per sala: Booked now, Minutes to next booking e un flag Prepare room che si attiva con un anticipo impostato prima di ogni prenotazione. Le smart rule usano il flag per riscaldare o raffrescare la sala e accendere luci e audio prima dell'arrivo del trainer, e per spegnerli quando la prenotazione termina. Sola lettura; serve l'accesso Live all'API, richiesto dal superadmin dello studio.

GlofoxPacket Parser → HTTP3 dispositiviRevisione 1.0 Ultimo aggiornamento: 10 novembre 2026

Inviato da Matej Hudec

Glofox room bookings — room preparation

Importa nell'app TapHomeHardware › Packet Parser › Aggiungi da modello

Scarica template
In questa pagina

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 (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: [email protected].

Guida alla richiesta di accesso nell'ABC Fitness Developer Portal

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
Dettaglio della facility con Public e Bookable attivi

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:

1
2
3
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

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

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:

OraBooked nowMinutes to next bookingPrepare room
8:30Free90Idle
9:00Free60Prepare
10:30Bookedprossima prenotazione o 1440Prepare
11:00Freeprossima prenotazione o 1440Idle

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

Prenotazione della facility nel calendario Glofox

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

Valori della sala nell'app TapHome

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

Glofox Room

Lettura (modulo)
# 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

Booked now

Lettura
RETURN(bookedNow);
Minutes to next booking Variabile

Minutes to next booking

Lettura
RETURN(minsToNext);
Prepare room Contatto reed

Prepare room

Lettura
RETURN(prepareRoom);
Connessione: Packet Parser → HTTP

Parametri di importazione

Inserisci questi valori quando importi l'XML.

Richiesto nell'appPredefinito
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 booking60

Hai trovato un problema con questo template?

Dicci cosa non funziona, cosa manca o come dovrebbe comportarsi il template. Il tuo feedback ci aiuta a mantenere il catalogo accurato.

Modello · portale TapHome Glofox room bookings — room preparation Apri questo template nel Customer Portal per applicarlo a una delle tue case, o crea una proposta di modifica e inviala al catalogo. Packet Parser → HTTP Vedi nel portale TapHome