Skip to content

[Feature] Add Notification Dispatcher and Device Status Check #3

Description

@p3ddd

目标

提升 HomeGuard 的可靠性和用户反馈机制。实现一个通用的通知调度器,并在发送 WoL 魔法包后,自动检测目标设备是否真的成功启动

描述

本功能分为两个紧密相关的部分:通用通知调度器和设备状态检测。

1. 通用通知调度器 (Notification Dispatcher)

  • 配置: 在 config.yaml 中新增一个 notifications: 配置块,允许用户配置一个或多个推送服务(例如 Gotify, Pushover, Pushbullet 等)。
  • 发送时机: 调度器应在以下关键时刻推送消息:
    • 魔法包发送成功: "Wake-up magic packet successfully sent to [device_name]."
    • 设备状态变更: "Device [device_name] is now online/offline." (由下文的状态检测触发)
    • 唤醒请求失败: "Error: Failed to wake [device_name]. Reason: [error]."

2. 设备状态检测 (Device Status Check)

  • 配置: 在 devices: 列表中为每个设备添加可选的检测配置,例如 ip: 和 check_port:。

    devices:
      - name: desktop
        mac: "..."
        ip: "192.168.1.10"  # 用于检测的 IP
        check_port: 22     # 可选:指定 TCP 端口 (如 SSH 22, RDP 3389)
        # 或使用 ICMP ping 检测:
        # check_method: "ping" 
  • 检测逻辑:

    1. 当 HomeGuard 成功发送 WoL 魔法包后,如果设备配置了 ip,则启动后台检测循环。
    2. 检测循环应尝试 Ping 该 IP(ICMP)或连接指定的 check_port(TCP)。
    3. 一旦检测成功(收到 Ping 回复或 TCP 连接建立),立即停止循环,并通过通知调度器发送设备上线通知。
    4. 应设置合理的超时和重试次数,以避免无限期等待。

预期效果

  • 用户可以获得一个明确的通知,确认唤醒请求已被处理。
  • 用户可以确定地知道设备是否真正启动并在线,而非仅仅魔法包被发送。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions