Commit Graph

44 Commits

Author SHA1 Message Date
Ryan Warner
c3fd24aa0b Adds iOS Live Activities support (#4444)
## Summary

> For architecture decisions, data model details, iOS version strategy,
push token flow, and rate limiting — see

[technical-brief.pdf](https://github.com/user-attachments/files/26280274/technical-brief.pdf)

Adds iOS Live Activities support, letting Home Assistant automations
push real-time state to the Lock Screen — washing machine countdowns, EV
charging progress, delivery tracking, alarm states, or anything
time-sensitive that benefits from glanceable visibility without
unlocking the phone.

When an automation sends a notification with `live_update: true` in the
data payload, the companion app starts a Live Activity instead of (or in
addition to) a standard notification banner. Subsequent pushes with the
same `tag` update it in-place silently. `clear_notification` + `tag`
ends it.

Field names (`tag`, `title`, `message`, `progress`, `progress_max`,
`chronometer`, `when`, `when_relative`, `notification_icon`,
`notification_icon_color`) are intentionally shared with Android's Live
Notifications API. Both platforms use the same `live_update: true`
trigger — a single YAML block targets iOS 17.2+ and Android 16+ with no
platform-specific keys.

```yaml
data:
  title: "Washing Machine"
  message: "Cycle in progress"
  data:
    tag: washer_cycle
    live_update: true           # Android 16+ and iOS 17.2+
    progress: 2700
    progress_max: 3600
    chronometer: true
    when: 2700
    when_relative: true
    notification_icon: mdi:washing-machine
    notification_icon_color: "#2196F3"
```

**New files:**
- `Sources/Shared/LiveActivity/HALiveActivityAttributes.swift` — the
`ActivityAttributes` type. Field names match the Android payload spec.
**Struct name and `CodingKeys` are wire-format frozen** — APNs
push-to-start payloads reference the Swift type name directly.
- `Sources/Shared/LiveActivity/LiveActivityRegistry.swift` — Swift
`actor` managing `Activity<HALiveActivityAttributes>` lifecycle. Uses a
reservation pattern to prevent duplicate activities when two pushes with
the same `tag` arrive simultaneously.
-
`Sources/Shared/Notifications/NotificationCommands/HandlerLiveActivity.swift`
— start/update and end `NotificationCommandHandler` implementations,
guarded against the `PushProvider` extension process where ActivityKit
is unavailable.
- `Sources/Extensions/Widgets/LiveActivity/` — `ActivityConfiguration`
wrapper, Lock Screen / StandBy view, and compact / minimal / expanded
Dynamic Island views.
- `Sources/App/Settings/LiveActivity/LiveActivitySettingsView.swift` —
activity status, active list, privacy disclosure, and 11 debug scenarios
for pre-server-side testing.

**Modified files:**
- `Widgets.swift` — registers `HALiveActivityConfiguration` in all three
`WidgetBundle` variants behind `#available(iOSApplicationExtension 17.2,
*)`
- `NotificationsCommandManager.swift` — registers new handlers;
`HandlerClearNotification` now also ends a matching Live Activity when
`tag` is present
- `HAAPI.swift` — adds `supports_live_activities`,
`supports_live_activities_frequent_updates`,
`live_activity_push_to_start_token`,
`live_activity_push_to_start_apns_environment` to registration payload
under a single `#available(iOS 17.2, *)` check
- `AppDelegate.swift` — reattaches surviving activities at launch and
starts observing push-to-start tokens under a single `#available(iOS
17.2, *)` check
- `Info.plist` — `NSSupportsLiveActivities` +
`NSSupportsLiveActivitiesFrequentUpdates`
- `SettingsItem.swift` / `SettingsView.swift` — Live Activities settings
row is gated behind `Current.isTestFlight` and shows a `BetaLabel` badge

**Tests:** 
 - *Unit Tests*
- 45 new tests (36 handler tests, 9 command manager routing tests). All
490 existing tests continue to pass.
 - *Device Tests*
- I tried to test with my physical device, however I do not have a paid
account. Turns out I could not deploy without disabling a lot of
entitlements for compilation. Even so, once I did get it deployed and
running Live Activities wouldn't show unless some of those settings that
I disable were re-enable and leaving me in a particular spot.
   - I mainly tested with the simulator which is what is shown below

## Screenshots


![full-debug-scenarios](https://github.com/user-attachments/assets/b6f61b15-8f41-4fb5-b89d-75b5de719056)

## Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#1303

## Link to pull request in push relay repository

Relay server: home-assistant/mobile-apps-fcm-push#278

## Link to pull request in HA core

Core: home-assistant/core#166072

## Any other notes

**iOS version gating at 17.2.** The entire feature is gated at
`#available(iOS 17.2, *)` — this is the minimum for push-to-start (the
primary server-side start mechanism). A single availability check now
covers all Live Activity APIs: `supports_live_activities`,
`frequentPushesEnabled`, push-to-start token, and all ActivityKit usage.
This eliminates the nested 16.2/17.2 check pattern.

**Push-to-start (iOS 17.2+) is client-complete.** The token is observed,
stored in Keychain, and included in registration payloads. All companion
server-side PRs are now open — relay server at
home-assistant/mobile-apps-fcm-push#278 and HA core webhook handlers at
home-assistant/core#166072. The relay server uses FCM's native
`apns.liveActivityToken` support (Firebase Admin SDK v13.5.0+) — no
custom APNs client or credentials needed.

> **Server-side work** — all PRs now open:
> - ~~`supports_live_activities` field handling in device registration~~
✓ home-assistant/core#166072
> - ~~`mobile_app_live_activity_token` webhook handler~~ ✓
home-assistant/core#166072
> - ~~`mobile_app_live_activity_dismissed` webhook handler~~ ✓
home-assistant/core#166072
> - ~~Relay server: Live Activity delivery via FCM
`apns.liveActivityToken`~~ ✓ home-assistant/mobile-apps-fcm-push#278
> - ~~`notify.py` routing: includes Live Activity APNs token alongside
FCM token~~ ✓ home-assistant/core#166072

**Live Activities entry in Settings is gated behind TestFlight.** The
settings row only appears when `Current.isTestFlight` is true,
preventing it from surfacing in a release build before the feature is
fully tested. A `BetaLabel` badge is shown alongside the row title.

**iPad:** `areActivitiesEnabled` is always `false` on iPad — Apple
system restriction. The Settings screen shows "Not available on iPad."
The registry silently no-ops. HA receives `supports_live_activities:
false` in the device registration for iPad.

**`HALiveActivityAttributes` is frozen post-ship.** The struct name
appears as `attributes-type` in APNs push-to-start payloads. Renaming it
silently breaks all remote starts. The `ContentState` `CodingKeys` are
equally frozen — only additions are safe. Both have comments in the
source calling this out.

**The debug section in Settings is intentional.** Gated behind `#if
DEBUG` so it only appears in debug builds — it never ships to TestFlight
or the App Store. It exercises the full ActivityKit lifecycle without
requiring the server-side chain.

**`UNUserNotificationCenter` in tests.** The `clear_notification` +
`tag` → Live Activity dismissal path is covered by code review rather
than a unit test. `HandlerClearNotification` calls
`UNUserNotificationCenter.current().removeDeliveredNotifications`
synchronously, which requires a real app bundle and throws
`NSInternalInconsistencyException` in the XCTest host. A comment in the
test file explains this.

**Rate limiting on iOS 18.** Apple throttles Live Activity updates to
~15 seconds between renders. Automations should trigger on state change
events, not polling timers.

**Related:**
- Community discussion:
https://github.com/orgs/home-assistant/discussions/84
- Android companion reference: https://github.com/home-assistant/android
- Roadmap: https://github.com/home-assistant/roadmap/issues/52

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Bruno Pantaleão Gonçalves <5808343+bgoncal@users.noreply.github.com>
2026-04-07 14:50:49 +02:00
Bruno Pantaleão Gonçalves
daa4a05714 Add experimental options to display iOS UI going edge to edge (#4279) 2026-01-29 20:59:51 +01:00
Copilot
35e52f7cfd Add auto-refresh for WebViewController after 5+ minutes in background with user setting (#4269) 2026-01-29 09:02:42 +00:00
Bruno Pantaleão Gonçalves
61a31ecc42 Allow frontend to display native toasts through external bus (#4191)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
2026-01-12 10:49:22 +01:00
Bruno Pantaleão Gonçalves
1cce18b72e Remove logic to clean frontend cache on server version change (#3787) 2025-09-03 13:51:51 -03:00
Bruno Pantaleão Gonçalves
b908fff567 Reset frontend cache when server version changes + refactor webView access (#3718)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
This PR adds functionality of resetting web cache when server version
changes and also refactor WebView direct access around the project,
becoming now private to WebViewController and only interactable through
the controller's protocol.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-07-14 15:13:03 +02:00
Bruno Pantaleão Gonçalves
cac8f15627 Add debug notifications option (#3674)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
This PR adds option in the debug section to receive debug notifications,
this is a debugging tool only and it is not visible to the user unless
it open the debugging tool hidden panel.

First use case: Receive notification when location fails to update ein
brackground.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-06-25 17:05:43 +02:00
Bruno Pantaleão Gonçalves
3699122425 Reset local push and set it as opt-in (#3647)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-06-12 13:13:36 +02:00
Bruno Pantaleão Gonçalves
3eca615fe0 Add support for /invite home assistant deeplink (#3591)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
Context: https://github.com/home-assistant/my.home-assistant.io/pull/544

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-05-12 13:57:58 +02:00
Bruno Pantaleão Gonçalves
d795dcc5cd Migrate "Settings -> General" to SwiftUI (#3558) 2025-04-22 19:39:41 +02:00
Bruno Pantaleão Gonçalves
3c30ab74cb Making "shake to debug" gesture configurable and optional (#3398)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-02-03 17:38:08 +01:00
Bruno Pantaleão Gonçalves
e21ea8761f Display bluetooth permission request until user make a choice (#3374)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
Before the screen was shown twice then never again if the user skips it,
but then there is no way for the user to manually enable bluetooth.
With this change the user can still close the permission screen but it
will be prompted again to make a choice as soon as devices &
integrations page loads.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2025-01-29 23:38:40 +01:00
Bruno Pantaleão Gonçalves
79c108bbe3 Add customizable gestures (#3238) 2024-12-05 17:55:52 +01:00
Bruno Pantaleão Gonçalves
e0d20f2da5 Add "Mac native features only" experimental mode (#3221)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
This opens HA server in safari instead of in the catalyst WKWebView

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
![CleanShot 2024-12-02 at 16 25
51@2x](https://github.com/user-attachments/assets/7e93bb29-8e23-45ad-ae46-c976ca2ed81c)
## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2024-12-03 11:10:45 +01:00
Bruno Pantaleão Gonçalves
f52351e4c9 Add bluetooth permission screen (#3104)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
![CleanShot 2024-10-29 at 16 16
18@2x](https://github.com/user-attachments/assets/76421e5e-6dc6-4405-955d-c90e003dceaf)
## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2024-10-29 17:35:26 +01:00
Bruno Pantaleão Gonçalves
779dec5658 Use extended PAN ID instead of mac extended addres to select thread network (#3060)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->

---------

Co-authored-by: Stefan Agner <stefan@agner.ch>
2024-09-26 16:31:59 +02:00
Bruno Pantaleão Gonçalves
30a81b015f Use home assistant defined thread network when commissioning matter device (#3027) 2024-09-25 00:03:47 +02:00
Bruno Pantaleão Gonçalves
186aea4fa7 Create Watch Home from iOS (#2944)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

- Create watch home from iPhone
- Configure Assist for watch from iPhone
- Deprecate message for iOS Actions
- Use Scripts or Scenes directly
- Show/Hide Assist in Apple Watch
- Options to require confirmation before running watch item
(script/scene/action)

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
![CleanShot 2024-08-27 at 15 52
39@2x](https://github.com/user-attachments/assets/5360c60d-9638-40b9-b799-d12668bd579f)


https://github.com/user-attachments/assets/1e4509f8-45e5-4b39-bfdc-62f9bce64617


## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2024-08-28 09:45:07 +02:00
Michal Šrůtek
c8852a3da4 Lowercase enum AppConfiguration (#2615)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->

As [lowerCamelCase came to Swift a long time
ago](https://www.hackingwithswift.com/swift/3.0/lower-camel-case), this
PR is changing the casing in `AppConfiguration`.
2024-02-29 13:28:26 +01:00
mat1th
113d4fe18f Update dependecy and cleanup code (#2581)
## Summary
This pr intruduces the following changes: 
- Upgrades the [Alomofire
dependecy](142efae0cc).
- Removes not needed [available
anotations](a4e71a3c88)
and split up code in multiple files; The anotations are not needed since
https://github.com/home-assistant/iOS/pull/2469.

## Screenshots
No user faceing changes

## Link to pull request in Documentation repository
NA

## Any other notes
NA
2024-02-23 15:04:00 +01:00
mat1th
97834bfd5e Update swift lint and format + appy fixes (#2585)
## Summary
Swift lint and swiftformat are outdated. This PR does update those +
applies the new formatting form swiftformat.
There is 1 swift file with a manual change:
`Sources/Vehicle/Templates/Areas/CarPlayAreasViewModel.swift`. This is
done because `swiftlint` did create the following swiftlint error:
`error: Cyclomatic Complexity Violation: Function should have complexity
10 or less; currently complexity is 11 (cyclomatic_complexity)`.

Because it does change a lot of files the question is if we want to
finetune the `swiftformat` rules.

## Screenshots
No user facing changes.

## Link to pull request in Documentation repository
NA

## Any other notes
NA
2024-02-22 13:06:39 +01:00
Bruno Pantaleão Gonçalves
e9c85b3f7a Drop iOS 12, 13 and 14 support (#2469)
<!-- Thank you for submitting a Pull Request and helping to improve Home
Assistant. Please complete the following sections to help the processing
and review of your changes. Please do not delete anything from this
template. -->

## Summary
<!-- Provide a brief summary of the changes you have made and most
importantly what they aim to achieve -->
Drop support for iOS 12 and 13.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
<!-- If there is any other information of note, like if this Pull
Request is part of a bigger change, please include it here. -->
2023-12-27 16:50:11 +01:00
Zac West
7e57d7d584 Add "Full Screen" setting (#2099)
Fixes #1720.

## Summary
On iPhone, this turns off the status bar text but continues to use the space, since the frontend doesn't handle the top safe area.

On iPad, this turns off the status bar and doesn't reserve any space.
2022-03-06 10:18:42 -08:00
Zac West
ab56fd7afa Revert "Remove Firebase (#2028)" (#2051)
This reverts commit 2c4bab1d5c.
2022-01-23 18:45:04 +00:00
Zac West
2c4bab1d5c Remove Firebase (#2028)
## Summary
Removes FCM and related SDKs in favor of using the server introduced in #2024.

## Any other notes
This will require testing. It may be worth reverting this PR to introduce a toggle if this lasts more than 1 beta cycle.

Future work includes figuring out the permanent location for these services; they are on fly.io right now but that may cost money, but for now I just want TestFlight builds to use it.
2021-12-26 09:01:29 +00:00
Zac West
502fb77c7c Fix menu bar template when deleting server it was set to (#1939)
## Summary
Need to fall back to any server if the server's gone. Other alternative is to reset the template to empty and pick a new server, but that felt a little bit more like losing the template unexpectedly.

## Any other notes
This can also be temporarily fixed by editing `~/Library/Group Containers/group.io.robbie.homeassistant/Library/Preferences/group.io.robbie.homeassistant.plist` and removing the `menuItemTemplate-server` key.
2021-11-27 23:47:22 -08:00
Zac West
5c104f76e9 Multi-server (#1906)
## Summary
Most, but not all, of the changes necessary to support multi-server throughout the app and all its features.

## Screenshots
| Light | Dark |
| ----- | ---- |
| ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 24](https://user-images.githubusercontent.com/74188/143670011-9b9905ac-1b5b-4a82-b9f3-1490465c4ec5.png) | ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 26](https://user-images.githubusercontent.com/74188/143670012-0080230a-8f68-4f34-9691-db9f5e825a83.png) |
| ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 30](https://user-images.githubusercontent.com/74188/143670015-ceeac558-e039-4639-a186-b5001ab418b8.png) | ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 29](https://user-images.githubusercontent.com/74188/143670016-d72bb69d-83f5-4197-a742-59d208467258.png) |
| ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 47](https://user-images.githubusercontent.com/74188/143670021-6c90c40f-c2f1-4a33-aad9-da6626e99d9d.png) | ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 52 45](https://user-images.githubusercontent.com/74188/143670024-e99de69d-61d8-4e12-be73-a172242806a0.png) |
| ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 53 05](https://user-images.githubusercontent.com/74188/143670033-1a41ac7e-d4d1-458b-974e-2efdaf8e2288.png) | ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 53 03](https://user-images.githubusercontent.com/74188/143670049-baf4db64-64db-4bfb-88cf-4930f9e5661b.png) |
| ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 53 21](https://user-images.githubusercontent.com/74188/143670053-7ec794f1-857c-4ef6-a92a-5318e90ac6b6.png) | ![Simulator Screen Shot - iPhone 13 Pro - 2021-11-26 at 21 53 19](https://user-images.githubusercontent.com/74188/143670056-a6a5207c-3bba-49fc-b5c6-fc6fa8141f9c.png) |

## Any other notes
- Encapsulates all connectivity, token & server-specific knowledge in a Server model object which gets passed around.
- Updates various places throughout the app to know about and use Server rather than accessing said information through non-server-specific methods.
- Visually requests/notes server in places where it's ambiguous. For example, the Open Page widget will gain a subtitle if multiple servers are set up.
- Allows switching which server is shown in the WebViews. Note that this doesn't take into account multi-window support on iPad/macOS yet.

Most things will migrate successfully however adding an additional server causes things like Shortcuts to start erroring requiring you specify which to use in the particular Shortcut.

Future work necessary:
- Model objects currently clobber each other if their identifiers match. For example, both servers having a zone named `home` means one of them wins the fight for which is known to the app.
- Being remotely logged out on any account causes the app to require onboarding again, when instead it should only do that if the last known server is logged out.
2021-11-27 12:33:46 -08:00
Zac West
4992c97b49 "Open page" widget (#1863)
## Summary
Adds to Shortcuts and Widgets the ability to open a particular page/panel in Lovelace.

## Screenshots
| State | 1 | 2 |
| -- | -- | -- |
| Empty | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 22 26 11](https://user-images.githubusercontent.com/74188/135033260-a54ac04e-e2dd-4da7-a497-b04d5297db8b.png) | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 22 26 57](https://user-images.githubusercontent.com/74188/135033274-d7dee9da-48f6-4219-8e47-c128746e26dc.png) |
| Contents | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 22 53 26](https://user-images.githubusercontent.com/74188/135033294-52953ad1-c73c-49ea-bc7b-919ce5c35068.png) | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 22 53 33](https://user-images.githubusercontent.com/74188/135033305-2d6c2e93-9ef0-485c-a533-e6ee34e17bfa.png) |
| Shortcuts | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 23 17 58](https://user-images.githubusercontent.com/74188/135033520-d5a848ca-c4f5-41aa-bba8-a27b9c80489a.png) | ![Simulator Screen Shot - iPad Pro (12 9-inch) (5th generation) - 2021-09-27 at 23 18 06](https://user-images.githubusercontent.com/74188/135033531-a2102fdc-c834-4994-bc4d-c97d7af93342.png) |

## Any other notes
A good starting point for widgets which need cached information. This one is simple: 1 request that is a small JSON payload that needs to be saved. This can start to get more complex later.

- Adds an on-disk cache backed by Codable, which we use to cache panels in the widget (for data) and in the app (to see if we need to reload the widget).
- Fixes some issues and crashes with opening the action of a widget multiple times in a row.
- Adds support for grabbing frontend localizations from Lokalise and uses them for panel localization.
2021-09-27 23:24:06 -07:00
Zac West
d939aa54d3 Reset badge to 0 automatically when opening the app (#1691)
## Summary
Adds a setting (defaulted on) to reset the badge to 0 when launching the app.

## Screenshots
| Light | Dark |
| -- | -- |
| ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-25 at 10 23 38](https://user-images.githubusercontent.com/74188/123462674-72f35c80-d59f-11eb-93d7-eaa021a021a2.png) | ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-25 at 10 23 40](https://user-images.githubusercontent.com/74188/123462699-7a1a6a80-d59f-11eb-9e23-238b7265e853.png) |

## Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#549

## Any other notes
This is the general behavior on most iOS apps, and should make micro-managing the badge a little easier.
2021-06-25 11:36:41 -07:00
Zac West
5e986773b2 Change crash reporting & analytics to opt-in (#1653)
## Summary
Disables crash reporting and analytics by default.

## Screenshots

| Light | Dark |
| -- | -- |
| ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-03 at 15 50 53](https://user-images.githubusercontent.com/74188/120721844-82d9be00-c483-11eb-960e-bd3a3b915211.png) | ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-03 at 15 50 55](https://user-images.githubusercontent.com/74188/120721846-866d4500-c483-11eb-83ab-675212011995.png) |

## Any other notes
- Users who have changed _any_ privacy setting have all of the values persisted, but users who have never done so will now find crash reporting and analytics disabled.
- Crash reporting being disabled explicitly prevents any communication with Sentry.
- Analytics doesn't actually do anything other than control whether error/warning logs are sent to Sentry if a crash occurs, so this doesn't really change much.
- Moves "Alerts" to under "Firebase" since it is prettier flow for them to be in that order.
- Done in response to Apple reject us (how many years since Robbie added these?!) but it's better with our ethos anyway.
2021-06-03 23:15:35 +00:00
Zac West
cf186c9b66 Location updates for reduced accuracy (#1583)
## Summary
Updates to reduced location accuracy, manual updates, and error message display.

## Screenshots
<img width="300" src="https://user-images.githubusercontent.com/74188/114497723-9a10d380-9bd7-11eb-8980-5fff8364424e.png">

![Image](https://user-images.githubusercontent.com/74188/114497774-b57bde80-9bd7-11eb-8a76-24814ea2dc70.png)
![Image-2](https://user-images.githubusercontent.com/74188/114497839-d04e5300-9bd7-11eb-9e4a-9b5e5edf0532.png)

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
- Shows error messages on the bottom of the screen, with as much room as they need. Fixes #311.
- Allows the reduced accuracy setting to send those poor accuracy results to the server. This should cut down on people who accidentally disabled full but don't realize it; seeing a location update with 3km precision should hopefully let 'em know.
- Adds a "Update Location" button to the Location settings.
- Updates the display of the "track_ios" hint (this one's for you Tom 😛).
2021-04-12 22:39:19 -07:00
Zac West
45ed8c5fb4 Update look and feel of settings (#1578)
## Summary
Updates the root of settings to have a few less options, use the new iOS 13+ 'inset grouped' style look with icons.

## Screenshots
![Image](https://user-images.githubusercontent.com/74188/114317710-3d6dc580-9abe-11eb-9dc1-264403eeaa9b.png)
![Image 2](https://user-images.githubusercontent.com/74188/114317706-3b0b6b80-9abe-11eb-8e56-8593ea859461.png)
<img width="350" alt="Screen Shot 2021-04-11 at 12 07 01" src="https://user-images.githubusercontent.com/74188/114317762-7d34ad00-9abe-11eb-8373-32c1da77df8d.png"><img width="350" alt="Screen Shot 2021-04-11 at 12 06 54" src="https://user-images.githubusercontent.com/74188/114317765-80c83400-9abe-11eb-8d9d-b60fd1f0d224.png">
<img width="350" alt="Screen Shot 2021-04-11 at 12 07 14" src="https://user-images.githubusercontent.com/74188/114317770-858ce800-9abe-11eb-82e5-8c7eb862dabb.png"><img width="350" alt="Screen Shot 2021-04-11 at 12 07 09" src="https://user-images.githubusercontent.com/74188/114317773-8756ab80-9abe-11eb-84d1-274216c550c7.png">

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes
- Moves a few things into 'Debugging' like resetting the app. Duplicates the entry point into location history (still in Location) since it's relevant there too.
- Removes the local 'AuthenticatedUser' cache (retrieved via WebView's WebSocket) in favor of the HAKit representation.
- Adds a debug-only "Add Server" button to the server list, which currently crashes when tapped.
2021-04-11 12:39:38 -07:00
Zac West
d3cd7f492c Add live-updating menu bar text template (#1529)
## Summary
Adds title configuration and template editing, based on the section used for editing complication templates. Whenever the subscription updates the text, we immediately update the status item.

## Screenshots
<img width="728" alt="image" src="https://user-images.githubusercontent.com/74188/110993976-ea70e900-832c-11eb-8476-454fb77a1981.png">
<img width="728" alt="image" src="https://user-images.githubusercontent.com/74188/110993710-7c2c2680-832c-11eb-8b35-50c72c9c23cc.png">
<img width="367" alt="image" src="https://user-images.githubusercontent.com/74188/110993728-851cf800-832c-11eb-885d-1787a2e5443b.png">
2021-03-12 12:47:47 -08:00
Zac West
433dde3ed0 Fix location settings for siglog changes & zones (#1478)
## Summary
The "Significant Location Change" and "Zone enter/exit" settings for Locations' Update Sources previously did not work. This now watches both settings for changes and handles enabling or disabling their respective monitoring.

## Any other notes
- It takes a few seconds for the location-in-use arrow to disappear after disabling them.
- Users may be a little surprised if things _stop_ working, since they may have toggled these off for some reason in the past.
2021-02-11 20:58:25 -08:00
Zac West
bf2c1bbcb6 Add setting to control pinch-to-zoom, defaulted off (#1472)
Refs home-assistant/frontend#8192.

## Summary
When enabled, pinch to zoom is allowed in the frontend. When disabled, which is the default, it is not allowed. This does not respect what the frontend sends for the values of `minimum-scale`, `maximum-scale` and `user-scalable` and instead overrides them.

## Screenshots
![Image](https://user-images.githubusercontent.com/74188/107317381-68e91b00-6a4f-11eb-9b14-ee5b4a3e7603.png)

## Any other notes
In home-assistant/frontend#7180, the frontend was changed to enable pinch to zoom in the app by removing the `user-scalable` flag. Browsers ignore this flag, but our UI is meant to feel like an app, not like a webpage. The accessibility part of the argument doesn't mirror iOS accessibility: dynamic type is how the system behaves and it doesn't scale elements like navigation or tab bars. To achieve an iOS-like accessibility experience, we have a setting to adjust only the text size in the frontend.

But we are not in total control over the contents of the users' dashboards or pages. There's layout and design choices that users may make which inherently don't work well on mobile without zooming on non-text elements, including other webapps. I believe this is a rare enough that disabled as a default is acceptable, but also common enough that the preference itself existing is worthwhile.

This works in all versions of iOS that we support, iOS 12 and above.
2021-02-09 20:20:54 -08:00
Zac West
640cca884b Add SwiftFormat to project (#1463)
Adds new fastlane lanes:
- `fastlane lint` which checks the linters
- `fastlane autocorrect` which applies the linters which can autocorrect (Rubocop, SwiftFormat)

Adds a build step to the Codegen abstract target which runs SwiftFormat in lint mode, pointing out what it's going to change when run.

Applies SwiftFormat to nearly all code -- exempts a few externally-sourced files and generated code.
2021-02-05 22:06:25 -08:00
Zac West
30b388aa39 Make server version optional, fixing an alert issue (#1402)
Fixes #1397.

## Summary
Makes server version optional, returning nil when we don't know rather than a fallback version.

## Screenshots
n/a

## Link to pull request in Documentation repository
n/a

## Any other notes
Prevents an issue where we'd alert about the fallback version being old enough to have an alert, rather than the actual version which comes later. Amusingly the work I did to make sure that we'd handle app-launch-to-web-view events supporting an onboarding flow in the middle causes the alerts to be delayed until the webview loads after initial login.
2021-01-22 23:01:49 -08:00
Zac West
293a149ba2 Add admin-only filtering for server-based alerts (#1401)
Fixes #1391.

## Summary
Adds optional flag `admin_only` to the alert definition. Doesn't show them when it's set and the current user isn't an admin.

## Link to pull request in Documentation repository
n/a
2021-01-22 22:32:58 -08:00
Zac West
e6324196e9 "Check for Updates" & "Alerts" settings (#1400)
Fixes #1378.

## Summary
- Adds a setting to control the automatic update checking, and an option to not include betas. 
- Adds a privacy option to disable server-side alerts.

## Screenshots
![image](https://user-images.githubusercontent.com/74188/105568347-754e4380-5ced-11eb-8640-45cc36faab48.png)
<img width="400" alt="Screen Shot 2021-01-22 at 20 32 04" src="https://user-images.githubusercontent.com/74188/105568780-e93e1b00-5cf0-11eb-8211-a19f228704bd.png"><img width="400" alt="Screen Shot 2021-01-22 at 20 31 59" src="https://user-images.githubusercontent.com/74188/105568782-eb07de80-5cf0-11eb-8dd3-214c5d0f54a4.png">
2021-01-22 20:57:02 -08:00
Zac West
d8355646a9 Allow showing in the menu bar, either additionally or exclusively (#1385)
Fixes #949 (the menu bar part).

## Summary
Allows configuring 2 potentially-mutually-exclusive things: whether to show the app in the dock, and whether to show a status item in the menu bar. Wraps them into one setting.

## Screenshots
<img width="400" alt="Screen Shot 2021-01-17 at 20 55 54" src="https://user-images.githubusercontent.com/74188/104874016-b833a400-5906-11eb-9269-4f65f6327173.png"><img width="400" alt="Screen Shot 2021-01-17 at 20 56 03" src="https://user-images.githubusercontent.com/74188/104874022-b964d100-5906-11eb-86b6-bc8836893638.png">
<img width="400" alt="Screen Shot 2021-01-17 at 20 56 19" src="https://user-images.githubusercontent.com/74188/104874044-cd103780-5906-11eb-9d83-19a2831fd859.png"><img width="400" alt="Screen Shot 2021-01-17 at 20 56 26" src="https://user-images.githubusercontent.com/74188/104874045-ce416480-5906-11eb-8b01-d22cf8b823c8.png">

Worth noting there seem to be something like 16 different permutations for the look of the menu bar. Here's some more!

<img width="311" alt="image" src="https://user-images.githubusercontent.com/74188/104874449-db128800-5907-11eb-851f-9b3383225dd3.png"><img width="442" alt="image" src="https://user-images.githubusercontent.com/74188/104874474-e8c80d80-5907-11eb-963f-a7ec2d28802d.png">

## Any other notes
- Positions the status item handling (routed through the Mac Bridge) in the same place that we handle menus on Catalyst, since the ultimate fate of the status item will be offering menus of some sort.
- Clicking on the status item hides or shows the app, depending on the current state. Effectively acts like a toggle. If there are no windows open when the app needs to be activated, creates a new webview window.
- Doesn't allow disabling both the menu bar item and the dock item, since the app isn't really set up for success with that.
2021-01-18 10:09:54 -08:00
Zac West
69101f7752 Updates for iOS 14's "Precise" location setting (#1342)
Fixes #776.

- Adds a temporary request for full accuracy when pulling-to-refresh.
- Prevents delays when sending sensor updates trying to get accurate locations when accuracy isn't full; we no longer consider ourselves having location permission when accuracy isn't full.
- Add "Location Accuracy" setting to Location settings, showing current state.
- Adds a warning to the Internal URL editing when accuracy isn't full, since it is required to get SSID information.
- Updates to use newer CLLocationManager "authorization changed!" methods in various places.
2021-01-03 18:41:59 -08:00
Zac West
1d3befe2cd Fix crash caused by background connection status change (#1203)
Fixes #1201. WebKit (unsurprisingly) really does not like being told to execute JavaScript off the main thread.
2020-10-17 22:01:45 -07:00
Zac West
dd15fb22e8 Aggressively watch for connection changes in WebView (#1158)
This moves the 'connection did change' notification from "we moved from internal to external" to "connection info changed in any way." For example, updating the connection settings will cause the WebView to immediately update, rather than requiring a pull-to-refresh.

- We now update the WebView URL and Settings "Connected Via" much more aggressively/reliably. Fixes #339.
- Comparing the 'should we reload?' for the URL now takes into account things like port being different.

This also avoids persisting/notifying ConnectionInfo changes when the values aren't changing. For example, every time we update our registration if it's just staying the same don't bother.
2020-10-06 09:18:42 -07:00
Zac West
4d9a530637 Reorganize files in repo, pull out build settings from pbxproj (#1140)
This is somewhat in prep of being able to make the project file generated, but also just organizes things into more concrete directory structures.

This pulls out _all_ of the build settings from the root level, and most from the target level, into xcconfigs.

The new directory structure looks like:

- Sources
  - App
    - (everything from HomeAssistant/)
  - WatchApp
  - Shared
  - MacBridge
  - Extensions
    - Intents
    - NotificationContent
    - NotificationService
    - Share
    - Today
    - Watch
    - Widgets
- Tests
  - App
  - UI
  - Shared

Somewhat intentionally, the file structure under these is not yet standardized/organized.

The project targets are now:

- App
- WatchApp
- Shared-iOS
- Shared-watchOS
- MacBridge
- Tests-App
- Tests-UI
- Tests-Shared
- Extension-Intents
- Extension-NotificationContent
- Extension-NotificationService
- Extension-Share
- Extension-Today
- Extension-Widget
- WatchExtension-Watch

This does not yet clean up resources vs. sources, nor does it handle some of the "it's in Sources/App but it's part of Shared" crossover directory issues.
2020-10-03 00:15:04 -07:00