Files
eink-push/main.py
YANG JIANKUAN 2121b1eff4 refactor: 推送改为局域网直连设备,推送前清空画廊旧图
原走 Zectrix 公网 API + 设备 MAC,现改为直连局域网墨水屏设备(喵喵固件)
的 HTTP 接口:POST /upload 推送 PNG 触发刷屏。设备画廊按追加保存,故推送
前先 GET /images 清空旧图,避免图片越推越多、且避免 slideshow 模式轮播
到过期图。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-07 10:19:10 +08:00

38 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
入口 —— 取数据 → 渲染 → 推送到设备。
用法:
python3 main.py # 渲染并推送(设备 host 取自 .env 的 EPD_HOST
python3 main.py --render-only # 只渲染生成图片不推送output/dashboard.png
配置统一从同目录 .env 读取(见 .env.example真实环境变量优先。
"""
import argparse
import config
from data import get_dashboard_data
from renderer import DashboardRenderer
def main():
parser = argparse.ArgumentParser(description="墨水屏仪表盘:渲染并推送")
parser.add_argument("--render-only", action="store_true", help="只渲染,不推送")
args = parser.parse_args()
data = get_dashboard_data()
path = DashboardRenderer().render_to_file(data, config.OUTPUT_PATH)
print(f"[渲染] 已生成 {path}")
if args.render_only:
return
from pusher import push_image
host, resp = push_image(path)
print(f"[推送] 设备 {host} 成功:{resp}")
if __name__ == "__main__":
main()