mirror of
https://github.com/home-assistant/iOS.git
synced 2026-06-16 13:26:27 -05:00
## Summary Adds support for Home Assistant automations in the iOS app. Automations can now be triggered from iOS Control Center widgets (iOS 18+), similar to existing script and scene controls. **Domain & Model** - Added `automation` domain with robot icon and `trigger` service - Included automation in `AppEntitiesModel` tracked domains for database caching - Added to CarPlay supported domains **Control Widget** (iOS 18+) - `ControlAutomation` - Main control widget - `AutomationAppIntent` - Triggers `automation.trigger` service - `IntentAutomationEntity` - Entity queries and selection - `ControlAutomationsValueProvider` - Configuration with custom icons/text **Pattern** Follows existing `ControlScript` and `ControlScene` implementation patterns for consistency. **Tests** - Updated `testWidgetsKindCasesValues` to include assertion for `controlAutomation` case - Updated widget kind count validation from 25 to 26 ## Screenshots N/A - Control widgets are system UI and cannot be screenshotted during development. Widget appears in Control Center configuration with automation icon and allows selection from available automations. ## Link to pull request in Documentation repository Documentation: home-assistant/companion.home-assistant# ## Any other notes Localization strings added for English only. Additional languages will need translation via the standard localization workflow. <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > 1 - Add "automation" in AppEntitiesModel domains > 2 - Create an iOS control for running automation like it exist for ControlScript </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/home-assistant/iOS/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
49 lines
2.8 KiB
Swift
49 lines
2.8 KiB
Swift
@testable import Shared
|
|
import Testing
|
|
|
|
struct ServiceTests {
|
|
@Test func testEnumCases() async throws {
|
|
// Test raw values
|
|
#expect(Service.turnOn.rawValue == "turn_on", "Service.turnOn raw value should be 'turn_on'")
|
|
#expect(Service.turnOff.rawValue == "turn_off", "Service.turnOff raw value should be 'turn_off'")
|
|
#expect(Service.toggle.rawValue == "toggle", "Service.toggle raw value should be 'toggle'")
|
|
#expect(Service.press.rawValue == "press", "Service.press raw value should be 'press'")
|
|
#expect(Service.lock.rawValue == "lock", "Service.lock raw value should be 'lock'")
|
|
#expect(Service.unlock.rawValue == "unlock", "Service.unlock raw value should be 'unlock'")
|
|
#expect(Service.open.rawValue == "open", "Service.open raw value should be 'open'")
|
|
#expect(Service.openCover.rawValue == "open_cover", "Service.openCover raw value should be 'open_cover'")
|
|
#expect(Service.closeCover.rawValue == "close_cover", "Service.closeCover raw value should be 'close_cover'")
|
|
#expect(Service.trigger.rawValue == "trigger", "Service.trigger raw value should be 'trigger'")
|
|
|
|
// Test initialization from raw value
|
|
#expect(Service(rawValue: "turn_on") == .turnOn, "Service(rawValue: 'turn_on') should initialize to .turnOn")
|
|
#expect(
|
|
Service(rawValue: "turn_off") == .turnOff,
|
|
"Service(rawValue: 'turn_off') should initialize to .turnOff"
|
|
)
|
|
#expect(Service(rawValue: "toggle") == .toggle, "Service(rawValue: 'toggle') should initialize to .toggle")
|
|
#expect(Service(rawValue: "press") == .press, "Service(rawValue: 'press') should initialize to .press")
|
|
#expect(Service(rawValue: "lock") == .lock, "Service(rawValue: 'lock') should initialize to .lock")
|
|
#expect(Service(rawValue: "unlock") == .unlock, "Service(rawValue: 'unlock') should initialize to .unlock")
|
|
#expect(Service(rawValue: "open") == .open, "Service(rawValue: 'open') should initialize to .open")
|
|
#expect(
|
|
Service(rawValue: "open_cover") == .openCover,
|
|
"Service(rawValue: 'open_cover') should initialize to .openCover"
|
|
)
|
|
#expect(
|
|
Service(rawValue: "close_cover") == .closeCover,
|
|
"Service(rawValue: 'close_cover') should initialize to .closeCover"
|
|
)
|
|
#expect(Service(rawValue: "trigger") == .trigger, "Service(rawValue: 'trigger') should initialize to .trigger")
|
|
|
|
// Test invalid raw value
|
|
#expect(Service(rawValue: "invalid") == nil, "Service(rawValue: 'invalid') should return nil")
|
|
|
|
// Test case count
|
|
#expect(
|
|
Service.allCases.count == 10,
|
|
"Service enum should have 10 cases, but has \(Service.allCases.count). Cases: \(Service.allCases.map(\.rawValue).joined(separator: ", "))"
|
|
)
|
|
}
|
|
}
|