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.
Mac: Open at Login, in the menu bar menu and the panel's gear menu
0xProbability88c84cca77fc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2ad7cd1..1a54288 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,14 @@What changed in each release of House Control. The Mac app is on[Releases](https://github.com/0xProbabillity/house-control/releases); the iPhone app is on TestFlight.+## Unreleased++### Mac++- **Open at Login**, in the menu bar icon's right-click menu and in the panel's gear menu: House Control starts with+ your Mac. It is the app's entry under System Settings → General → Login Items, so it can be switched off there too.+ Run from the disk image, the app asks to be moved to Applications first; moved there later, the login item follows it.+## 1.0.0 — 2026-10-15### Widgets, controls and quick actionsdiff --git a/README.md b/README.mdindex 0bfdf12..0d3350c 100644--- a/README.md+++ b/README.md@@ -117,8 +117,9 @@ The app is signed ad hoc. If you rebuild often and use iPhone sync, sign it withmacOS does not ask for the Local Network permission after every build:`CODESIGN_IDENTITY="Apple Development: [email protected] (ABCDE12345)" ./scripts/build-app.sh`.-To keep it, drag `build/HouseControl.app` into `/Applications`. To start it with your Mac, add it under-**System Settings → General → Login Items**.+To keep it, drag `build/HouseControl.app` into `/Applications`. To start it with your Mac, turn on **Open at+Login** in the menu bar icon's right-click menu (or in the panel's gear menu); it shows up under+**System Settings → General → Login Items**, where it can be switched off too.There is no Dock icon and no main window: look for the house in the menu bar.@@ -127,7 +128,7 @@ There is no Dock icon and no main window: look for the house in the menu bar.| Do this | To get this || --- | --- || Click the menu bar icon | Open or close the panel |-| Right-click the menu bar icon | Edit Home, Load Floor Plan, Reveal Plan File, Reveal Device Log, Show Island, Pair iPhone, AI Access, Reload, Quit |+| Right-click the menu bar icon | Edit Home, Load Floor Plan, Reveal Plan File, Reveal Device Log, Show Island, Open at Login, Pair iPhone, AI Access, Reload, Quit || Click a lamp in the 3D view, or its tile | Toggle it || Drag sideways across a light tile | Dim it || Click the sliders icon on a light tile | Brightness, white temperature, colour |diff --git a/macos/Sources/HouseControl/AppDelegate.swift b/macos/Sources/HouseControl/AppDelegate.swiftindex d8debd3..ee4387c 100644--- a/macos/Sources/HouseControl/AppDelegate.swift+++ b/macos/Sources/HouseControl/AppDelegate.swift@@ -67,6 +67,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {host.load()startSync()if islandEnabled { showIsland() }+ LoginItem.followMove()// HOUSE_SNAPSHOT_DIR=<folder> writes panel.png and island.png there a few seconds// after launch: a look at the UI without a screen (see HOUSE_RENDER_HIDDEN).@@ -182,6 +183,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {let islandItem = menu.addItem(withTitle: "Show Island", action: #selector(toggleIsland), keyEquivalent: "")islandItem.target = selfislandItem.state = island?.isShown == true ? .on : .off+ let login = LoginItem.state+ let loginItem = menu.addItem(withTitle: login == .needsApproval ? "Open at Login — Allow in Settings…" : "Open at Login",+ action: #selector(toggleOpenAtLogin), keyEquivalent: "")+ loginItem.target = self+ loginItem.state = login == .on ? .on : login == .needsApproval ? .mixed : .offmenu.addItem(withTitle: "Pair iPhone…", action: #selector(pairPhone), keyEquivalent: "").target = selflet aiItem = menu.addItem(withTitle: agent.isLive ? "AI Access — Live" : "AI Access…", action: #selector(openAgent), keyEquivalent: "")aiItem.target = self@@ -208,6 +214,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {private func togglePanel() {guard let button = statusItem.button else { return }panel.toggle(below: button)+ // It can be switched off in System Settings too: the panel's menu shows what is true now.+ if panel.isVisible { panel.host.call("openAtLogin", LoginItem.state.rawValue) }}// MARK: - Plans@@ -228,6 +236,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {default: break}boot["agentLive"] = agent.isLive+ boot["openAtLogin"] = LoginItem.state.rawValue// HOUSE_OPEN_DEVICE=<id> starts the panel on that light's or AC's detail sheet.if let device = ProcessInfo.processInfo.environment["HOUSE_OPEN_DEVICE"] { boot["openDevice"] = device }return boot@@ -367,6 +376,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {case "revealPlan": revealPlan()case "openEditor": openEditor()case "quit": NSApp.terminate(nil)+ case "setOpenAtLogin": setOpenAtLogin(message["on"] as? Bool ?? false)// Editorcase "savePlan":@@ -549,6 +559,31 @@ final class AppDelegate: NSObject, NSApplicationDelegate {if show { showIsland() } else { island?.hide() }}+ // MARK: - Open at Login++ /// Waiting for approval counts as off: choosing it again takes the user to System Settings.+ @objc private func toggleOpenAtLogin() { setOpenAtLogin(LoginItem.state != .on) }++ private func setOpenAtLogin(_ on: Bool) {+ if on, LoginItem.isTemporaryCopy {+ alert("Move House Control to Applications first",+ "It is running from the disk image or from a temporary copy of the download, which is gone after a restart. "+ + "Drag House Control into the Applications folder, open it from there, then turn on Open at Login.")+ return+ }+ do {+ try LoginItem.set(on)+ } catch {+ alert(on ? "Could not add House Control to Login Items" : "Could not remove House Control from Login Items",+ "\(error.localizedDescription)\n\nYou can change it in System Settings → General → Login Items.")+ }+ panel.host.call("openAtLogin", LoginItem.state.rawValue)+ // The very first registration can take a moment to show in the status.+ DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in+ self?.panel.host.call("openAtLogin", LoginItem.state.rawValue)+ }+ }+// MARK: - iPhone sync/// The name paired iPhones see (HOUSE_COMPUTER_NAME replaces it for screenshots).diff --git a/macos/Sources/HouseControl/LoginItem.swift b/macos/Sources/HouseControl/LoginItem.swiftnew file mode 100644index 0000000..c7ad8cc--- /dev/null+++ b/macos/Sources/HouseControl/LoginItem.swift@@ -0,0 +1,60 @@+import Foundation+import ServiceManagement++/// "Open at Login": the app registers itself as a login item, the one listed in+/// System Settings → General → Login Items, where it can be switched off as well.+@MainActor+enum LoginItem {+ enum State: String { case on, off, needsApproval }++ static var state: State {+ switch SMAppService.mainApp.status {+ case .enabled: return .on+ case .requiresApproval: return .needsApproval+ default: return .off+ }+ }++ /// Run from the disk image, or from the temporary place macOS runs a downloaded app from until it has+ /// been moved (App Translocation): a login item would point at a copy that is gone after a restart.+ static var isTemporaryCopy: Bool {+ let url = Bundle.main.bundleURL+ if url.path.contains("/AppTranslocation/") { return true }+ return (try? url.resourceValues(forKeys: [.volumeIsReadOnlyKey]))?.volumeIsReadOnly == true+ }++ /// In /Applications or ~/Applications, where a copy is meant to stay.+ private static var isInstalled: Bool {+ let folder = Bundle.main.bundleURL.deletingLastPathComponent().path+ return folder == "/Applications" || folder == NSHomeDirectory() + "/Applications"+ }++ /// Where the app was when it registered.+ private static let registeredPathKey = "loginItemPath"++ /// Switches it on or off. When macOS wants the user to allow it first, opens Login Items for them.+ static func set(_ on: Bool) throws {+ let service = SMAppService.mainApp+ if on {+ if service.status == .requiresApproval {+ SMAppService.openSystemSettingsLoginItems()+ return+ }+ // Registering again points the login item at this copy of the app.+ if service.status == .enabled { try? service.unregister() }+ try service.register()+ UserDefaults.standard.set(Bundle.main.bundlePath, forKey: registeredPathKey)+ if service.status == .requiresApproval { SMAppService.openSystemSettingsLoginItems() }+ } else if service.status == .enabled || service.status == .requiresApproval {+ try service.unregister()+ }+ }++ /// At launch: when the app has been moved into Applications since it registered, the login item+ /// follows it. Copies run from anywhere else (a build folder, say) leave it alone.+ static func followMove() {+ guard state == .on, isInstalled,+ UserDefaults.standard.string(forKey: registeredPathKey) != Bundle.main.bundlePath else { return }+ try? set(true)+ }+}diff --git a/web/src/main.js b/web/src/main.jsindex c44a6f9..3ae95fa 100644--- a/web/src/main.js+++ b/web/src/main.js@@ -143,6 +143,9 @@ async function boot() {};incoming.agentLive = (live) => panel.setAgentLive(Boolean(live));panel.setAgentLive(Boolean(window.__HOUSE_BOOT__?.agentLive));+ // 'on', 'off' or 'needsApproval' (switched on, waiting to be allowed in System Settings).+ let openAtLogin = window.__HOUSE_BOOT__?.openAtLogin || 'off';+ incoming.openAtLogin = (state) => { openAtLogin = state; };store.onDeviceError = (id, message) => {const name = store.lightCfg.get(id)?.name || store.acCfg.get(id)?.name || id;@@ -180,6 +183,11 @@ async function boot() {{ label: 'Load floor plan…', action: () => post('loadPlan') },{ label: 'Reveal plan file', action: () => post('revealPlan') },'-',+ {+ label: openAtLogin === 'needsApproval' ? 'Open at login — allow in Settings…' : 'Open at login',+ icon: openAtLogin === 'on' ? icon('check', 16, 2.4) : null,+ action: () => post('setOpenAtLogin', { on: openAtLogin !== 'on' }),+ },{ label: 'Quit House Control', action: () => post('quit') });}openMenu(panel.anchorMenu, anchor, items);