Skip to content

Fix SwitchIntent to handle more domains such as input_boolean #3515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Sources/Extensions/Widgets/Controls/Switch/SwitchIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ struct SwitchIntent: SetValueIntent {
service = value ? HAServices.turnOn : HAServices.turnOff
}

// This intent can also handle for example, input_boolean
let domain = Domain(entityId: entity.entityId) ?? .switch

let _ = await withCheckedContinuation { continuation in
connection.send(.callService(
domain: .init(stringLiteral: Domain.switch.rawValue),
domain: .init(stringLiteral: domain.rawValue),
service: .init(stringLiteral: service),
data: [
"entity_id": entity.entityId,
]
)).promise.pipe { result in
print(result)
)).promise.pipe { _ in
continuation.resume()
}
}
Expand Down
Loading