Your home as a live 3D model in the Mac menu bar and on iPhone — lights and ACs via Smart Life, Home Assistant, Philips Hue and Apple Home.
iPhone: a House Control control that opens the app
0xProbabilityf7e302a5d3a8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1a54288..240439d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,13 @@ What changed in each release of House Control. The Mac app is on## Unreleased+### iPhone++- **House Control in Control Center:** a button that opens the app, for Control Center, the Lock Screen and the+ Action button (iOS 18). It opens on the home in 3D and, made wide, says how the home is ("6 on · AC 23°"); tap it+ while editing Control Center to have it open the floor plan editor or settings instead. **Open House Control** is+ in Shortcuts too.+### Mac- **Open at Login**, in the menu bar icon's right-click menu and in the panel's gear menu: House Control starts withdiff --git a/README.md b/README.mdindex 0d3350c..058a41f 100644--- a/README.md+++ b/README.md@@ -268,7 +268,7 @@ Every widget is live: tap a lamp, a scene or an AC and it switches without openi**Climate** (an AC's dial with the room temperature, power and − / +).- **Lock Screen:** Home Status, Light and Climate as circles, rectangles and an inline line.- **Controls** for Control Center, the Lock Screen and the Action button (iOS 18, macOS 26): All Lights, a Light,- a Scene, an Air Conditioner.+ a Scene, an Air Conditioner, and on the iPhone **House Control**, which opens the app.- **Quick actions:** press and hold the app icon on the iPhone. Choose which scenes, lamps and ACs it offers in**Settings → Quick Actions**.diff --git a/docs/widgets.md b/docs/widgets.mdindex 7c5c7a1..05e660f 100644--- a/docs/widgets.md+++ b/docs/widgets.md@@ -17,7 +17,9 @@ without opening the app.Controls (iOS 18 and macOS 26): **All Lights** (toggle), **Light** (toggle, pick the lamp), **Scene** (button, pick thescene) and **Air Conditioner** (toggle, pick the AC). On the iPhone they go into Control Center, onto the Lock-Screen and onto the Action button; on the Mac into Control Center and the menu bar.+Screen and onto the Action button; on the Mac into Control Center and the menu bar. The iPhone also has+**House Control** (button): it opens the app on the home, the floor plan editor or settings, and shows how the home+is when it is made wide ("6 on · AC 23°").Quick actions (iPhone): press and hold the app icon for up to four of your scenes, lamps and ACs.Pick them in **Settings → Quick Actions**: add with **+**, drag to reorder, swipe to remove. Each home has its own set;@@ -60,6 +62,7 @@ widget tap ─▶ AppIntent ─▶ HomeSnapshot.apply ─▶ home.json (at once)| `core/Sources/HouseCore/WidgetBridge.swift` | The app's side: stores snapshots, hands queued actions to the panel || `web/src/widgets.js` | Builds the snapshot in the panel page and runs queued actions (`house.widget`) || `widgets/Sources/` | Widgets, controls, intents and the isometric model (`HouseModel.swift`), shared by iPhone and Mac |+| `widgets/Sources/OpenApp.swift` | The intent that opens the app on a screen; compiled into the iPhone app as well, where it runs || `widgets/project.yml` | The Mac's widget extension (built and embedded by `scripts/build-app.sh`) || `ios/project.yml` | The iPhone's widget extension (target `HouseWidgets`) || `ios/Sources/QuickActions.swift` | The icon's quick actions and their editor |diff --git a/ios/Sources/AppModel.swift b/ios/Sources/AppModel.swiftindex bcc7767..3dbaa0e 100644--- a/ios/Sources/AppModel.swift+++ b/ios/Sources/AppModel.swift@@ -180,6 +180,7 @@ final class AppModel {}widgets.onSnapshot = { [weak self] in self?.quickActions.update(home: $0) }QuickActionCenter.handler = { [weak self] id, title in self?.runQuickAction(id, title: title) }+ OpenAppRouter.handler = { [weak self] in self?.open($0) }web.onMessage = { [weak self] in self?.handle($0) }web.load { [weak self] in self?.bootPayload() ?? [:] }@@ -576,12 +577,19 @@ final class AppModel {// MARK: - Mac sync/// A `housecontrol://pair?…` link, from the camera, the clipboard or another app, or- /// `housecontrol://open?device=…` from a widget.+ /// `housecontrol://open?device=…` from a widget, `housecontrol://open?screen=editor|settings`+ /// from a link (the House Control control itself runs `OpenHouseControlIntent`).@discardableResultfunc open(_ url: URL) -> Bool {if url.scheme == SyncPairing.scheme, url.host == "open" {+ let query = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems ?? []+ if let screen = query.first(where: { $0.name == "screen" })?.value.flatMap(AppScreen.init(rawValue:)),+ screen != .home {+ open(screen)+ return true+ }showSettings = false- let device = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.first { $0.name == "device" }?.value+ let device = query.first { $0.name == "device" }?.valueif let device {if pageReady { web.call("openDevice", device) } else { pendingDevice = device }}@@ -592,6 +600,22 @@ final class AppModel {return true}+ /// The screen the House Control control (or Shortcuts) asked for. The welcome and new-home+ /// sheets come first: then the app just opens.+ func open(_ screen: AppScreen) {+ guard !showWelcome, !showNewHome else { return }+ switch screen {+ case .home:+ showSettings = false+ case .editor:+ openEditor()+ case .settings:+ guard !showEditor else { return }+ settingsPath = []+ showSettings = true+ }+ }+func pair(_ pairing: SyncPairing) {sync.pair(pairing)macName = pairing.namediff --git a/ios/project.yml b/ios/project.ymlindex 4dad694..14e15cd 100644--- a/ios/project.yml+++ b/ios/project.yml@@ -21,6 +21,8 @@ targets:sources:- path: Sources- path: Resources+ # The intent the "House Control" control runs to open the app: both sides have to know it.+ - path: ../widgets/Sources/OpenApp.swift# The web UI, built by `npm run build` in ../web; lands in the app as the folder "dist".- path: ../web/disttype: folderdiff --git a/widgets/Sources/Controls.swift b/widgets/Sources/Controls.swiftindex 5961b90..81fc57f 100644--- a/widgets/Sources/Controls.swift+++ b/widgets/Sources/Controls.swift@@ -196,3 +196,64 @@ struct SceneControl: ControlWidget {.promptsForUserConfiguration()}}++#if os(iOS)+@available(iOS 18.0, *)+struct OpenControlConfiguration: ControlConfigurationIntent {+ static let title: LocalizedStringResource = "House Control"+ @Parameter(title: "Open", default: .home) var screen: AppScreen+}++/// A button that opens the app: on the home in 3D (and says how it is), the editor or settings.+@available(iOS 18.0, *)+struct OpenAppControl: ControlWidget {+ static let kind = "io.github.0xprobabillity.HouseControl.open-control"++ struct Value {+ var screen: AppScreen+ var status: String+ var lit: Bool+ }++ struct Provider: AppIntentControlValueProvider {+ func previewValue(configuration: OpenControlConfiguration) -> Value {+ value(configuration.screen, home: HomeData.orSample)+ }++ func currentValue(configuration: OpenControlConfiguration) async throws -> Value {+ value(configuration.screen, home: HomeData.current)+ }++ private func value(_ screen: AppScreen, home: HomeSnapshot?) -> Value {+ switch screen {+ case .home:+ guard let home else { return Value(screen: screen, status: "Open", lit: false) }+ // Short enough for the wide tile: "6 on · AC 23°", "2 lights on", "Lights off".+ let ac = home.acsOn.first+ let lights = home.lightsOn == 0 ? "Lights off"+ : ac == nil ? "\(home.lightsOn) \(home.lightsOn == 1 ? "light" : "lights") on" : "\(home.lightsOn) on"+ let status = ac.map { "\(lights) · AC \($0.targetText)" } ?? lights+ return Value(screen: screen, status: status, lit: home.lightsOn > 0 || ac != nil)+ case .editor: return Value(screen: screen, status: "Floor Plan", lit: false)+ case .settings: return Value(screen: screen, status: "Settings", lit: false)+ }+ }+ }++ var body: some ControlWidgetConfiguration {+ AppIntentControlConfiguration(kind: Self.kind, provider: Provider()) { value in+ ControlWidgetButton(action: OpenHouseControlIntent(screen: value.screen)) {+ Label {+ Text("House Control")+ Text(value.status)+ } icon: {+ Image(systemName: value.screen == .home && !value.lit ? "house" : value.screen.symbol)+ }+ }+ .tint(Palette.warm)+ }+ .displayName("House Control")+ .description("Opens the app: the home in 3D, the floor plan or settings.")+ }+}+#endifdiff --git a/widgets/Sources/HouseWidgets.swift b/widgets/Sources/HouseWidgets.swiftindex fc63874..e2c2413 100644--- a/widgets/Sources/HouseWidgets.swift+++ b/widgets/Sources/HouseWidgets.swift@@ -19,6 +19,9 @@ struct HouseWidgets: WidgetBundle {@WidgetBundleBuilderprivate var controls: some Widget {if #available(iOS 18.0, macOS 26.0, *) {+ #if os(iOS)+ OpenAppControl()+ #endifAllLightsControl()LightControl()SceneControl()diff --git a/widgets/Sources/OpenApp.swift b/widgets/Sources/OpenApp.swiftnew file mode 100644index 0000000..ca22862--- /dev/null+++ b/widgets/Sources/OpenApp.swift@@ -0,0 +1,67 @@+#if os(iOS)+import AppIntents+import Foundation++// Opening the app from a control (Control Center, the Lock Screen, the Action button) and from+// Shortcuts. This file is part of the app as well as of the widget extension: an intent that+// opens the app has to be known to both, and the system runs it in the app.++/// Where the app opens.+enum AppScreen: String, AppEnum {+ case home, editor, settings++ static let typeDisplayRepresentation: TypeDisplayRepresentation = "Screen"+ static let caseDisplayRepresentations: [AppScreen: DisplayRepresentation] = [+ .home: DisplayRepresentation(title: "Home", subtitle: "The home in 3D", image: .init(systemName: "house.fill")),+ .editor: DisplayRepresentation(title: "Floor Plan", subtitle: "The editor", image: .init(systemName: "pencil.and.ruler.fill")),+ .settings: DisplayRepresentation(title: "Settings", subtitle: "Connections, sync, quick actions", image: .init(systemName: "gearshape.fill")),+ ]++ var symbol: String {+ switch self {+ case .home: "house.fill"+ case .editor: "pencil.and.ruler.fill"+ case .settings: "gearshape.fill"+ }+ }+}++/// Hands the screen an intent asks for to the app. The intent runs in the app's own process+/// (`openAppWhenRun`), so the app's model takes it from here; one that comes before the model+/// is ready waits in `pending`.+@MainActor+enum OpenAppRouter {+ static var handler: ((AppScreen) -> Void)? {+ didSet {+ guard let handler, let screen = pending else { return }+ pending = nil+ handler(screen)+ }+ }+ static var pending: AppScreen?++ static func open(_ screen: AppScreen) {+ if let handler { handler(screen) } else { pending = screen }+ }+}++@available(iOS 18.0, *)+struct OpenHouseControlIntent: AppIntent {+ static let title: LocalizedStringResource = "Open House Control"+ static let description = IntentDescription("Opens House Control on the home, the floor plan editor or settings.")+ static let openAppWhenRun = true++ @Parameter(title: "Screen", default: .home) var screen: AppScreen++ init() {}+ init(screen: AppScreen) { self.screen = screen }++ static var parameterSummary: some ParameterSummary { Summary("Open House Control on \(\.$screen)") }++ @MainActor+ func perform() async throws -> some IntentResult {+ OpenAppRouter.open(screen)+ return .result()+ }+}+#endif