Ai Fitness Studio Utilization via RESTful Sensor in Home Assistant

Hi everyone,

I built an automation for AI Fitness Studios since evidence of anyone using their API was scarce. By inspecting their website and some JavaScript keys, I deduced the tenant name and API endpoint, similar to what was done for FitX.

Finding the Studio UID
To get the UID for your desired studio, follow these steps:

  • Open the studio website (for example: https://www.ai-fitness.de/studios/essen).
  • Open the developer tools and navigate to the Sources tab.
  • Use CTRL+F and search for:
    <section class="studio-occupancy-wrapper" data-studio-id="1289045240"></section>
  • The number found in the data-studio-id attribute is the UID you need.
    Keep in mind that this UID may change occasionally, so you might have to update it from time to time.

YAML Configuration
Below is the Home Assistant configuration:

  - platform: rest
    name: "AI Borbeck"
    unique_id: "ai_borbeck"
    resource: "https://dein.ai-fitness.de/nox/public/v1/studios/1289045240/utilization"
    headers:
      x-tenant: bestfit
    value_template: >
      {% set val = value_json['items']  | selectattr('isCurrent', 'equalto', true) | map(attribute='percentage') | list | first | default(0) %}
      {{ val | round(0) }}
    scan_interval: 600
    unit_of_measurement: "%"
    state_class: measurement
    icon: mdi:dumbbell

Replace the studio ID with the UID you found from the website.

Dashboard Note
I’ve also created a dynamic dashboard that sorts studios by their current utilization percentage, and I’ve included a screenshot of it. This dashboard helps quickly determine which gym is least crowded.

image

type: custom:auto-entities
card:
  type: entities
  title: Auslastungen 🚗 (sortiert nach %)
  state_color: false
filter:
  include:
    - entity_id: sensor.ai*
sort:
  method: state
  numeric: true

Cheers! :blush:

1 Like

that was what i was searching for. thank you :slight_smile:

1 Like