Swiftpack.co - c-st/HAClient as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by c-st.
c-st/HAClient v1.0.0-beta1
A Swift client for the HomeAssistant websocket API.
⭐️ 0
🕓 37 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/c-st/HAClient.git", from: "v1.0.0-beta1")

HAClient

HAClient

A Swift client for the HomeAssistant WebSocket API.

Usage

Add HAClient to your project

Add the following lines to your Package.swift or use Xcode's "Add Package Dependency…" menu.

// `Package.swift`

dependencies: [
    // ...
    .package(url: "https://github.com/c-st/HAClient.git"),
    // ...
]

Use in your code

let url = "ws://homeassistant.raspberrypi.localdomain/api/websocket"
let client = HAClient(messageExchange: WebSocketClient(url))

// Authenticate
let token = "insert long-lived access token"
try await client.authenticate(token: token)

// Make API requests
let areas = try await client.listAreas()
let devices = try await client.listDevices()
let entities = try await client.listEntities()
let states = try await client.retrieveStates()

Reference

WebSocket API documentation

GitHub

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

Dependencies

Release Notes

v1.0.0-beta1
37 weeks ago

Initial release of HAClient

Requires Swift 5.5 and macOS Monterey as it uses some of Swift's new concurrency features.

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