This skill allows you to interact with Withings accounts for multiple family members to retrieve comprehensive health metrics from Withings devices (smart scales, sleep analyzers, activity trackers, etc.).
Multi-User Support
This skill natively supports multiple users with per-user token files:
CODEBLOCK0
Each family member authenticates once via OAuth. Their tokens are stored separately and refreshed automatically. No token copying or switching required — just pass the user ID as the first argument.
CODEBLOCK1
When to Use This Skill
Use this skill when the user:
- - Asks about their weight or weight history
- Wants to see their body composition (fat %, muscle mass, bone mass, hydration)
- Requests their daily activity (steps, distance, calories burned)
- Asks about their sleep data (duration, quality, deep sleep, REM)
- Mentions "Withings" or any Withings device (Body+, Sleep Analyzer, ScanWatch, etc.)
- Wants to track their or their family's health progress over time
Setup: Creating a Withings Developer App
Before using this skill, you need to create a free Withings developer application to get your API credentials.
Step 1: Create a Withings Developer Account
- 1. Go to Withings Developer Portal
- Click Sign Up or Log In if you already have a Withings account
- Accept the Developer Terms of Service
Step 2: Create Your Application
- 1. Navigate to My Apps → Create an Application
- Fill in the application details:
-
Application Name: Choose a name (e.g., "My Moltbot Health")
-
Description: Brief description of your use case
-
Contact Email: Your email address
-
Callback URL:
http://localhost:18081 (required for OAuth)
-
Application Type: Select "Personal Use" or appropriate type
- 3. Submit the application
Step 3: Get Your Credentials
Once your application is created:
- 1. Go to My Apps and select your application
- You'll find:
-
Client ID → Set as
WITHINGS_CLIENT_ID environment variable
-
Client Secret → Set as
WITHINGS_CLIENT_SECRET environment variable
Step 4: Configure Environment Variables
Add these to your Moltbot environment:
CODEBLOCK2
Or create a .env file in ~/.openclaw/withings-family/.env (legacy: ~/.moltbot/withings-family/.env):
CODEBLOCK3
Configuration
The skill provides two scripts (in scripts/):
- -
scripts/withings_oauth_local.py — Automatic OAuth with local callback server (recommended) scripts/withings.py — Main CLI + manual OAuth
Credentials location: ~/.openclaw/withings-family/ (legacy: ~/.moltbot/withings-family/)
- -
.env — Client ID/Secret (optional, can use ENV vars instead) - INLINECODE12 — OAuth tokens per user (mode 600)
Before any data retrieval, check if the user is authenticated. If an error mentions "No token found", guide the user through the initial authentication process for that specific user.
Authentication Methods
Method A: Automatic OAuth (Recommended)
Uses a local callback server to capture the code automatically:
CODEBLOCK4
Example:
CODEBLOCK5
The script will:
- 1. Print the authorization URL
- Start a local server on localhost:18081
- Wait for the redirect
- Automatically capture the code and exchange for tokens
- Save tokens to INLINECODE13
Method B: Manual OAuth
Traditional two-step flow (see "Authentication" command below).
Available Commands
All commands follow the format:
CODEBLOCK6
1. Authentication
First-time setup for a user — generates the OAuth URL:
CODEBLOCK7
After the user visits the URL and gets the authorization code:
CODEBLOCK8
Repeat for each family member who needs access.
2. Get Weight
Retrieve the latest weight measurements:
CODEBLOCK9
Returns the 5 most recent weight entries in JSON format.
Example output:
CODEBLOCK10
3. Get Body Composition
Retrieve comprehensive body metrics (fat, muscle, bone, water, BMI):
CODEBLOCK11
Returns the 5 most recent body composition measurements.
Example output:
CODEBLOCK12
4. Get Activity
Retrieve daily activity data (steps, distance, calories):
CODEBLOCK13
Optionally specify the number of days (default: 7):
CODEBLOCK14
Example output:
CODEBLOCK15
5. Get Sleep
Retrieve sleep data and quality:
CODEBLOCK16
Optionally specify the number of days (default: 7):
CODEBLOCK17
Example output:
CODEBLOCK18
Error Handling
Common errors and how to resolve them:
| Error | Cause | Solution |
|---|
| "No token found" | User not authenticated | Run python3 scripts/withings.py <userId> auth and follow the OAuth flow |
| "Failed to refresh token" |
Token expired and refresh failed | Re-authenticate with
python3 scripts/withings.py <userId> auth |
| "API Error Status: 401" | Invalid or expired credentials | Check your CLIENT
ID and CLIENTSECRET, re-authenticate |
| "API Error Status: 503" | Withings API temporarily unavailable | Wait and retry later |
| Empty data | No measurements in the requested period | User needs to sync their Withings device |
Notes
- - Multi-user: Each family member has their own token file (
tokens-{userId}.json) - Token refresh: Tokens are automatically refreshed when they expire
- Scopes: Withings API scopes used:
user.metrics, INLINECODE18 - Device support: Data availability depends on which Withings devices the user owns
- Body composition: Requires a compatible smart scale (e.g., Body+, Body Comp)
技能名称: withings-family
详细描述:
此技能允许您与Withings账户进行交互,支持多个家庭成员,从而从Withings设备(智能秤、睡眠分析仪、活动追踪器等)获取全面的健康指标。
多用户支持
该技能原生支持多用户,每个用户拥有独立的令牌文件:
tokens-alice.json
tokens-bob.json
tokens-charlie.json
每位家庭成员通过OAuth进行一次身份验证。他们的令牌会分别存储并自动刷新。无需复制或切换令牌——只需将用户ID作为第一个参数传入即可。
bash
python3 scripts/withings.py alice weight
python3 scripts/withings.py bob sleep
python3 scripts/withings.py charlie activity
何时使用此技能
当用户出现以下情况时,可使用此技能:
- - 询问他们的体重或体重历史
- 想要查看他们的身体成分(体脂率、肌肉量、骨量、水分率)
- 请求查看他们的日常活动(步数、距离、消耗卡路里)
- 询问他们的睡眠数据(时长、质量、深度睡眠、快速眼动睡眠)
- 提及Withings或任何Withings设备(Body+、Sleep Analyzer、ScanWatch等)
- 想要追踪他们自己或家人的健康进展
设置:创建Withings开发者应用
在使用此技能之前,您需要创建一个免费的Withings开发者应用程序以获取API凭证。
步骤1:创建Withings开发者账户
- 1. 访问 Withings开发者门户
- 点击注册,如果您已有Withings账户则点击登录
- 接受开发者服务条款
步骤2:创建您的应用程序
- 1. 导航至我的应用 → 创建应用
- 填写应用详细信息:
-
应用名称:选择一个名称(例如,我的Moltbot健康)
-
描述:简要描述您的使用场景
-
联系邮箱:您的电子邮件地址
-
回调URL:http://localhost:18081(OAuth必需)
-
应用类型:选择个人使用或合适的类型
- 3. 提交应用程序
步骤3:获取您的凭证
创建应用程序后:
- 1. 前往我的应用并选择您的应用
- 您将找到:
-
客户端ID → 设置为 WITHINGS
CLIENTID 环境变量
-
客户端密钥 → 设置为 WITHINGS
CLIENTSECRET 环境变量
步骤4:配置环境变量
将这些添加到您的Moltbot环境中:
bash
export WITHINGSCLIENTID=yourclientid_here
export WITHINGSCLIENTSECRET=yourclientsecret_here
或者在 ~/.openclaw/withings-family/.env(旧版:~/.moltbot/withings-family/.env)中创建一个 .env 文件:
WITHINGSCLIENTID=yourclientid_here
WITHINGSCLIENTSECRET=yourclientsecret_here
配置
该技能提供两个脚本(位于 scripts/ 目录):
- - scripts/withingsoauthlocal.py — 使用本地回调服务器的自动OAuth(推荐)
- scripts/withings.py — 主命令行界面 + 手动OAuth
凭证位置: ~/.openclaw/withings-family/(旧版:~/.moltbot/withings-family/)
- - .env — 客户端ID/密钥(可选,也可使用环境变量)
- tokens-.json — 每个用户的OAuth令牌(权限模式600)
在检索任何数据之前,请检查用户是否已通过身份验证。如果错误提示未找到令牌,请引导该特定用户完成初始身份验证流程。
身份验证方法
方法A:自动OAuth(推荐)
使用本地回调服务器自动捕获授权码:
bash
python3 {baseDir}/scripts/withingsoauthlocal.py
示例:
bash
python3 {baseDir}/scripts/withingsoauthlocal.py alice
该脚本将:
- 1. 打印授权URL
- 在localhost:18081上启动本地服务器
- 等待重定向
- 自动捕获授权码并交换为令牌
- 将令牌保存到 tokens-.json
方法B:手动OAuth
传统的两步流程(参见下面的身份验证命令)。
可用命令
所有命令遵循以下格式:
bash
python3 {baseDir}/scripts/withings.py [options]
1. 身份验证
用户的首次设置——生成OAuth URL:
bash
python3 {baseDir}/scripts/withings.py alice auth
用户访问URL并获取授权码后:
bash
python3 {baseDir}/scripts/withings.py alice auth YOURCODEHERE
为每位需要访问的家庭成员重复此操作。
2. 获取体重
检索最新的体重测量数据:
bash
python3 {baseDir}/scripts/withings.py alice weight
以JSON格式返回最近5条体重记录。
示例输出:
json
[
{ date: 2026-01-17T08:30:00.000Z, weight: 75.40 kg },
{ date: 2026-01-16T08:15:00.000Z, weight: 75.65 kg }
]
3. 获取身体成分
检索全面的身体指标(脂肪、肌肉、骨骼、水分、BMI):
bash
python3 {baseDir}/scripts/withings.py alice body
返回最近5次身体成分测量数据。
示例输出:
json
[
{
date: 2026-01-17T08:30:00.000Z,
weight: 75.40 kg,
fat_percent: 18.5%,
fat_mass: 13.95 kg,
muscle_mass: 35.20 kg,
bone_mass: 3.10 kg,
hydration: 55.2%
}
]
4. 获取活动
检索日常活动数据(步数、距离、卡路里):
bash
python3 {baseDir}/scripts/withings.py alice activity
可选择指定天数(默认:7天):
bash
python3 {baseDir}/scripts/withings.py alice activity 30
示例输出:
json
[
{
date: 2026-01-17,
steps: 8542,
distance: 6.23 km,
calories: 2150,
active_calories: 450,
soft_activity: 45 min,
moderate_activity: 22 min,
intense_activity: 8 min
}
]
5. 获取睡眠
检索睡眠数据和质量:
bash
python3 {baseDir}/scripts/withings.py alice sleep
可选择指定天数(默认:7天):
bash
python3 {baseDir}/scripts/withings.py alice sleep 14
示例输出:
json
[
{
date: 2026-01-17,
start: 23:15,
end: 07:30,
duration: 8h 15min,
deep_sleep: 1h 45min,
light_sleep: 4h 30min,
rem_sleep: 1h 30min,
awake: 30min,
sleep_score: 82
}
]
错误处理
常见错误及解决方法:
| 错误 | 原因 | 解决方法 |
|---|
| 未找到令牌 | 用户未通过身份验证 | 运行 python3 scripts/withings.py <userId> auth 并按照OAuth流程操作 |
| 刷新令牌失败 |
令牌已过期且刷新失败 | 使用 python3 scripts/withings.py
auth 重新进行身份验证 |
| API错误状态:401 | 凭证无效或已过期 | 检查您的CLIENTID和CLIENTSECRET,重新进行身份验证 |
| API错误状态:503 | Withings API暂时不可用 | 稍后重试 |
| 数据为空 | 请求时间段内没有测量数据 | 用户需要同步他们的Withings设备 |
注意事项
- - 多用户: 每位家庭成员拥有自己的令牌文件(tokens-{userId}.json)
- 令牌刷新: 令牌过期时会自动刷新
- 权限范围: 使用的Withings API范围:user.metrics、user.activity
- 设备支持: 数据可用性取决于用户拥有的Withings设备
- 身体成分: 需要兼容