FitX Gym Utilization

Hello everyone,

I’m training in a FitX-Gym since a couple of years now and since the beginning of the pandemic they released a feature to see the current utilization of the studio. Raukze released a custom HACS integration a while back which crawls the FitX-Website as they had a graph on it to show the utilization. With a change of their system infrastructure they changed it and released a more or less public API to request those infos. I integrated that new API into the custom integration which kind of broke with the HA Release 2023.4. Since the integration just retrieved Rest-API data, it could be implemented with a RESTful Sensor natively built into HA. The data from the API looks something like this:

{
  "startTime": "00:00:00",
  "endTime": "00:00:00",
  "items": [
    {
      "startTime": "00:00:00",
      "endTime": "01:00:00",
      "percentage": 1,
      "level": "LOW",
      "isCurrent": false
    },
    {
      "startTime": "01:00:00",
      "endTime": "02:00:00",
      "percentage": 1,
      "level": "LOW",
      "isCurrent": false
    },

...

    {
      "startTime": "12:00:00",
      "endTime": "13:00:00",
      "percentage": 59,
      "level": "NORMAL",
      "isCurrent": true
    },

...

    {
      "startTime": "22:00:00",
      "endTime": "23:00:00",
      "percentage": 0,
      "level": "LOW",
      "isCurrent": false
    },
    {
      "startTime": "23:00:00",
      "endTime": "00:00:00",
      "percentage": 0,
      "level": "LOW",
      "isCurrent": false
    }
  ]
}

This array has always been sorted by the date. This is the reason why a rather easy implementation of a restsensor is possible:

- platform: rest
  resource: https://mein.fitx.de/nox/public/v1/studios/1561099930/utilization
  headers:
    x-tenant: fitx
  icon: mdi:weight-lifter
  name: FitX Auslastung
  unique_id: fitx
  unit_of_measurement: "%"
  value_template: >-
    {% for item in value_json['items'] if item.isCurrent %}
      {{ item.percentage }}
    {% endfor %}

To use this sensor in your own region, you have to change the studio id (in the above example: 1561099930) to your own studio id. To do this do the following:

  1. Download this Gist: Get the ID of a FitX Studio by it's name. · GitHub
  2. Run it like this: python fitx_id.py bielefeld-mitte
  3. It should return Something like this:
Searching ID for Gym bielefeld-mitte...
Found the ID for bielefeld-mitte: 1516366190
  1. Use the given ID in the sensor.

It’s showing the following in HomeAssistant:
Screenshot 2023-04-07 122156

4 Likes