FritzBox 套件0.5.0

FritzBox-Kit 0.5.0

Roman Gille 维护。



 
依赖
AEXML>= 0
XMLMapper>= 0
 

  • 作者
  • Roman Gille

Fritz!Box 套件

CocoaPods Swift Package Manager compatible GitHub GitHub Workflow Status

此套件旨在成为一个框架,为与 Fritz!Box 路由器通信提供干净和现代的 Swift API。重点是家庭自动化功能。

功能

  • 使用 API 进行认证
  • 加载设备信息(当前仅限于恒温器和开关)
  • 切换开关
  • 设置恒温器温度
  • 加载恒温器时间表
  • 操作恒温器时间表

基础

使用您的 myfritz URL 和用户凭据创建 SDK 实例。

let fritzBox = FritzBox(
    host: "https://YOURID.myfritz.net:46048",
    user: "foo",
    password: "bar"
)

通过调用 login 方法获取会话标识符。这将被用于所有后续请求。

fritzBox.login { result in
    if case .success(let info) = result {
        print("Info: \(String(describing: info))")
        // We are now ready to do further requests.
    }
}

现在您可以获取有关设备的详细信息,并对它们进行操作。

fritzBox.getDevices(completion: { result in
    if case .success(let devices) = result {
        print("Devices: \(String(describing: devices))")
        // Prints a list of devices and their properties.
    }
})

硬件

由于我只有一个家庭,因此以下配置仅进行过测试。

  • Fritz!Box 7490(FRITZ!OS 6.83)
  • 3 个 FRITZ!Dect 300 恒温器
  • 1 个 FRITZ!Dect 301 恒温器

安装

当使用 Swift 包管理器 时,请添加以下内容

.package(url: "https://github.com/r-dent/FritzBoxKit.git", from: "0.5.0")

如果您使用的是 CocoaPods,请将以下内容添加到您的 Podfile 中

pod 'FritzBox-Kit'