Swiftpack.co - lawrencebensaid/SwiftHK as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by lawrencebensaid.
lawrencebensaid/SwiftHK v0.1
HomeKit for Swift is a package which allows you to interact with HomeKit in a modern way.
⭐️ 2
🕓 3 weeks ago
iOS macOS watchOS
.package(url: "https://github.com/lawrencebensaid/SwiftHK.git", from: "v0.1")

HomeKit for Swift (SwiftHK)

HomeKit for Swift is a package which allows you to interact with HomeKit in a modern way.

import SwiftHK


let home = Manager().home

// Print power status of all services
for service in home.services {
    let isOn = try await service.fetch(.powerState)
    print("\(service.name) is \(isOn == true ? "ON" : "OFF")")
}

// Switch everything off
for service in home.services {
    try await service.fetch(.powerState)
}

Example output:

Lightbulb L4MT is ON
Lightbulb 8D21 is OFF
Outlet P92E is ON

NOTE: This project is a WORK IN PROGRESS. It is unfinished subject to change!

GitHub

link
Stars: 2
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

HomeKit for Swift v0.1
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics