Goal: Sync health parameters like body weight, goals, and battery metrics from Withings Smart Body Analyzer scale using OAuth2 authentication.
Why CLI Scripts? (Agentic AI Observability)
Before jumping into the script code, it is important to understand why command-line scripts are extremely useful for modern smart homes. Beyond convenience for terminal users, these CLI scripts act as a programmatic interface (API bridge) for agentic AI assistants like Antigravity (agy).
By exposing Home Assistant states through standard shell scripts, an AI agent running in your workspace can query, check, and verify live IoT metrics or network states autonomously. This enables the agent to check if the network is healthy, read environment levels, or verify configurations without having to scrape web-based dashboards or utilize complex browser interfaces. It bridges human developer terminal workflows with agentic automation.
Step-by-Step Configuration
1. Register a Withings Developer App
Withings integrations require a personal application to handle OAuth authentication:
- Log in to the Withings Developer Portal.
- Click Create Application.
- Set the callback redirect URI:
https://my.home-assistant.io/redirect/oauth - Copy the generated Client ID and Client Secret.
2. Configure Withings in Home Assistant
- In Home Assistant UI, go to Settings -> Devices & Services -> Add Integration.
- Select Withings.
- Choose the OAuth option, paste your Client ID and Client Secret.
- Authenticate using your Withings user account when redirected. Select the user profile matching the scale statistics.
3. Accessing Scale Telemetry
The integration exposes your scale’s status:
# Querying weight sensor goal
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.withings_weight_goal
Withings Weight Goal: 80.0 kg
# Querying battery level of the Smart Body Analyzer
$ /home/gvoina/scripts/get_ha_sensor.sh sensor.smart_body_analyzer_battery
Smart Body Analyzer Battery: 85 %
