Skip to content

Fix Apple Shortcuts failing after iCloud sync between devices#1128

Open
timbms wants to merge 2 commits intodevelopfrom
fix/shortcut-home-stable-identifier
Open

Fix Apple Shortcuts failing after iCloud sync between devices#1128
timbms wants to merge 2 commits intodevelopfrom
fix/shortcut-home-stable-identifier

Conversation

@timbms
Copy link
Copy Markdown
Contributor

@timbms timbms commented Apr 5, 2026

Summary

Fixes #1125

Shortcuts created on one device fail on another with "Invalid home: the value provided for home in Get Item State was invalid" after iCloud sync.

Root cause: OpenHABHome.identifier stored a device-local UUID. UUIDs are generated independently on each device, so the UUID stored in a synced shortcut has no match in the second device's storedHomes.

Fix: Replace the UUID with a stable cross-device identifier derived from the home's connection configuration:

Home type Identifier used
myopenhab.org cloudUserId (unique per cloud account)
Self-hosted with remote URL Remote connection URL
Local-only Local connection URL
Demo / no URLs UUID (no cross-device benefit, but avoids regression)

This identifier is identical on every device configured for the same openHAB server, so iCloud-synced shortcuts resolve correctly without any user action.

Migration: Shortcuts created before this fix stored a UUID. The lookup now falls back to UUID matching transparently on first run, then Shortcuts saves the new stable identifier format going forward — no user intervention needed.

Changes

  • OpenHABIntentHelper: new stableIdentifier(for:) and resolveHomeId(for:) helpers; updated resolveHome, getHomeOptions, and getAllItems to use them
  • All 7 intent handlers: replaced direct Preferences.shared.storedHomes[UUID] lookup with resolveHomeId(for:), which handles both new and legacy identifier formats

Test plan

  • Create a shortcut using a Get/Set item action on Device A, confirm it works
  • Sync to Device B via iCloud, confirm it runs without "Invalid home" error
  • Confirm shortcuts created before this fix (UUID-based) still work on the original device
  • Confirm shortcuts created before this fix work on a second device after sync (legacy UUID migration path)

timbms and others added 2 commits April 5, 2026 17:37
The OpenHABHome shortcut parameter stored a device-local UUID as its
identifier. Since UUIDs are generated independently on each device,
shortcuts synced via iCloud could not resolve the home on the second
device, resulting in "Invalid home" errors.

Replace the UUID with a stable cross-device identifier derived from
the home's connection configuration: cloudUserId (for myopenhab.org
accounts), remote URL (for self-hosted servers), or local URL as a
fallback. This identifier is identical on every device configured for
the same openHAB instance, so synced shortcuts resolve automatically.

Legacy shortcuts that stored a UUID are migrated transparently: the
lookup falls back to UUID matching on first run, then Shortcuts saves
the new stable identifier format going forward.

Fixes #1125

Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apple Shortcuts synchronised fail because “home” definition does not synchronise between different IoS devices

1 participant