Garmer - Garmin Data Extraction Skill
This skill enables extraction of health and fitness data from Garmin Connect for analysis and insights.
Prerequisites
- 1. A Garmin Connect account with health data
- The
garmer CLI tool installed (see installation options in metadata)
Authentication (One-Time Setup)
Before using garmer, authenticate with Garmin Connect:
CODEBLOCK0
This will prompt for your Garmin Connect email and password. Tokens are saved to ~/.garmer/garmin_tokens for future use.
To check authentication status:
CODEBLOCK1
Available Commands
Daily Summary
Get today's health summary (steps, calories, heart rate, stress):
CODEBLOCK2
Sleep Data
Get sleep analysis (duration, phases, score, HRV):
CODEBLOCK3
Activities
List recent fitness activities:
CODEBLOCK4
Activity Detail
Get detailed information for a single activity:
CODEBLOCK5
Health Snapshot
Get comprehensive health data for a day:
CODEBLOCK6
Export Data
Export multiple days of data to JSON:
CODEBLOCK7
Utility Commands
CODEBLOCK8
Python API Usage
For more complex data processing, use the Python API:
CODEBLOCK9
User Profile
CODEBLOCK10
Daily Summary
CODEBLOCK11
Sleep Data
CODEBLOCK12
Activities
CODEBLOCK13
Heart Rate
CODEBLOCK14
Stress & Body Battery
CODEBLOCK15
Steps
CODEBLOCK16
Body Composition
CODEBLOCK17
Hydration & Respiration
CODEBLOCK18
Comprehensive Reports
CODEBLOCK19
Common Workflows
Health Check Query
When a user asks "How did I sleep?" or "What's my health summary?":
CODEBLOCK20
Activity Analysis
When a user asks about workouts or exercise:
CODEBLOCK21
Trend Analysis
When analyzing health trends over time:
CODEBLOCK22
Then process the JSON file with Python for analysis.
Data Types Available
- - Activities: Running, cycling, swimming, strength training, etc.
- Sleep: Duration, phases (deep, light, REM), score, HRV
- Heart Rate: Resting HR, samples, zones
- Stress: Stress levels, body battery
- Steps: Total steps, distance, floors
- Body Composition: Weight, body fat, muscle mass
- Hydration: Water intake tracking
- Respiration: Breathing rate data
Error Handling
If not authenticated:
CODEBLOCK23
If session expired, re-authenticate:
CODEBLOCK24
Environment Variables
- -
GARMER_TOKEN_DIR: Custom directory for token storage - INLINECODE3 : Set logging level (DEBUG, INFO, WARNING, ERROR)
- INLINECODE4 : Enable/disable data caching (true/false)
References
For detailed API documentation and MoltBot integration examples, see references/REFERENCE.md.
Garmer - Garmin 数据提取技能
此技能支持从 Garmin Connect 提取健康和健身数据,用于分析和洞察。
前提条件
- 1. 拥有包含健康数据的 Garmin Connect 账户
- 已安装 garmer CLI 工具(安装选项请参见元数据)
身份验证(一次性设置)
使用 garmer 前,需先通过 Garmin Connect 进行身份验证:
bash
garmer login
系统将提示输入 Garmin Connect 邮箱和密码。令牌将保存至 ~/.garmer/garmin_tokens 供后续使用。
检查身份验证状态:
bash
garmer status
可用命令
每日摘要
获取今日健康摘要(步数、卡路里、心率、压力):
bash
garmer summary
指定日期:
garmer summary --date 2025-01-15
包含昨晚睡眠数据:
garmer summary --with-sleep
garmer summary -s
JSON 格式输出(便于程序化使用):
garmer summary --json
组合参数:
garmer summary --date 2025-01-15 --with-sleep --json
睡眠数据
获取睡眠分析(时长、阶段、评分、HRV):
bash
garmer sleep
指定日期:
garmer sleep --date 2025-01-15
活动记录
列出近期健身活动:
bash
garmer activities
限制结果数量:
garmer activities --limit 5
按指定日期筛选:
garmer activities --date 2025-01-15
JSON 格式输出:
garmer activities --json
活动详情
获取单个活动的详细信息:
bash
最新活动:
garmer activity
按 ID 指定活动:
garmer activity 12345678
包含圈数据:
garmer activity --laps
包含心率区间数据:
garmer activity --zones
JSON 格式输出:
garmer activity --json
组合参数:
garmer activity 12345678 --laps --zones --json
健康快照
获取某天的综合健康数据:
bash
garmer snapshot
指定日期:
garmer snapshot --date 2025-01-15
JSON 格式输出:
garmer snapshot --json
数据导出
将多天数据导出为 JSON:
bash
最近 7 天(默认)
garmer export
自定义日期范围
garmer export --start-date 2025-01-01 --end-date 2025-01-31 --output my_data.json
最近 N 天
garmer export --days 14
实用命令
bash
更新 garmer 至最新版本(git pull):
garmer update
显示版本信息:
garmer version
Python API 使用
如需更复杂的数据处理,可使用 Python API:
python
from garmer import GarminClient
from datetime import date, timedelta
使用已保存的令牌
client = GarminClient.from
savedtokens()
或使用凭据登录
client = GarminClient.from_credentials(email=user@example.com, password=pass)
用户资料
python
获取用户资料
profile = client.get
userprofile()
print(f用户:{profile.display_name})
获取已注册设备
devices = client.get
userdevices()
每日摘要
python
获取每日摘要(默认为今日)
summary = client.get
dailysummary()
print(f步数:{summary.total_steps})
获取指定日期
summary = client.get
dailysummary(date(2025, 1, 15))
获取每周摘要
weekly = client.get
weeklysummary()
睡眠数据
python
获取睡眠数据(默认为今日)
sleep = client.get_sleep()
print(f睡眠:{sleep.total
sleephours:.1f} 小时)
获取昨晚睡眠
sleep = client.get
lastnight_sleep()
获取日期范围睡眠数据
sleep
data = client.getsleep_range(
start_date=date(2025, 1, 1),
end_date=date(2025, 1, 7)
)
活动记录
python
获取近期活动
activities = client.get
recentactivities(limit=5)
for activity in activities:
print(f{activity.activity
name}:{activity.distancekm:.1f} 公里)
带筛选条件获取活动
activities = client.get_activities(
start_date=date(2025, 1, 1),
end_date=date(2025, 1, 31),
activity_type=running,
limit=20
)
按 ID 获取单个活动
activity = client.get_activity(12345678)
心率
python
获取某天心率数据
hr = client.get
heartrate()
print(f静息心率:{hr.resting
heartrate} bpm)
仅获取静息心率
resting
hr = client.getresting
heartrate(date(2025, 1, 15))
压力与身体电量
python
获取压力数据
stress = client.get_stress()
print(f平均压力:{stress.avg
stresslevel})
获取身体电量数据
battery = client.get
bodybattery()
步数
python
获取详细步数数据
steps = client.get_steps()
print(f总计:{steps.total
steps},目标:{steps.stepgoal})
仅获取总步数
total = client.get
totalsteps(date(2025, 1, 15))
身体成分
python
获取最新体重
weight = client.get
latestweight()
print(f体重:{weight.weight_kg} 公斤)
获取指定日期体重
weight = client.get_weight(date(2025, 1, 15))
获取完整身体成分
body = client.get
bodycomposition()
水分与呼吸
python
获取水分数据
hydration = client.get_hydration()
print(f摄入量:{hydration.total
intakeml} 毫升)
获取呼吸数据
resp = client.get_respiration()
print(f平均呼吸:{resp.avg
wakingrespiration} 次/分钟)
综合报告
python
获取健康快照(某天所有指标)
snapshot = client.get
healthsnapshot()
返回:dailysummary, sleep, heartrate, stress, steps, hydration, respiration
获取每周健康报告及趋势
report = client.get
weeklyhealth_report()
返回:活动摘要、睡眠统计、步数统计、心率趋势、压力趋势
导出日期范围数据
data = client.export_data(
start_date=date(2025, 1, 1),
end_date=date(2025, 1, 31),
include_activities=True,
include_sleep=True,
include_daily=True
)
常见工作流
健康查询
当用户询问我睡得怎么样?或我的健康摘要是什么?时:
bash
garmer snapshot --json
活动分析
当用户询问锻炼或运动情况时:
bash
garmer activities --limit 10
趋势分析
分析一段时间内的健康趋势时:
bash
garmer export --days 30 --output health_data.json
然后使用 Python 处理 JSON 文件进行分析。
可用数据类型
- - 活动:跑步、骑行、游泳、力量训练等
- 睡眠:时长、阶段(深睡、浅睡、REM)、评分、HRV
- 心率:静息心率、样本数据、区间
- 压力:压力水平、身体电量
- 步数:总步数、距离、楼层数
- 身体成分:体重、体脂率、肌肉量
- 水分:饮水追踪
- 呼吸:呼吸频率数据
错误处理
未通过身份验证时:
未登录。请先使用 garmer login 登录。
会话过期时,请重新验证:
bash
garmer login
环境变量
- - GARMERTOKENDIR:令牌存储的自定义目录
- GARMERLOGLEVEL:设置日志级别(DEBUG、INFO、WARNING、ERROR)
- GARMERCACHEENABLED:启用/禁用数据缓存(true/false)
参考
有关详细 API 文档和 MoltBot 集成示例,请参见 references/REFERENCE.md。