101 Commits

Author SHA1 Message Date
Zac West
7631aa5110
Changeable local name for servers (#1945)
Changes the server name row into an editable one, persists along with the server and uses it everywhere. Basically identical to 'device name' in functionality there.

Also hides the 'activate' button if there's only one server.
2021-11-28 15:51:11 -08:00
Zac West
a165444a95
Fix crash adding new server with scene actions (#1943)
Fixes regression from #1941.

## Summary
The default value of `.max` isn't adjusted to a real one until after onboarding is finished, but we do a model fetch _during_ onboarding to test that it works.
2021-11-28 19:41:18 +00:00
Zac West
5145a7784d
Fix crash by making Current reentrant during setup (#1940) 2021-11-28 18:50:49 +00:00
Zac West
f728fb5588
Fix scene actions not setting the right server or sort order (#1941) 2021-11-28 18:47:42 +00:00
Zac West
a3cf326d7b
Store zones by server, allowing duplicate entity ids (#1936)
## Summary
Stores a zone from s1 in Realm like `s1/zone.name` rather than `zone.name` so it's distinct from `s2/zone.name`. This is most apparent for `zone.home` which universally conflicts.

## Any other notes
This does not yet extend to the other synced models as we use their identifier in persisted locations that aren't programmatically changeable (e.g. action IDs are stored in intents). Zones don't pose such a problem, and are the most likely suspect to even have duplicates right now; scenes, actions, and deprecated notification categories can be done after an external beta.
2021-11-28 04:39:29 +00: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
3d181b0f77
Fix onboarding error 404 when URL has a trailing / (#1915)
## Summary
Fixes receiving "Alamofire.AFError 9" with a response status code of 404 during onboarding when a URL like `http://192.168.1.3:8123/` (with trailing slash) is provided.

## Any other notes
The real crux of this issue is that ConnectionInfo strips it, but the connectivity check in onboarding does not, giving us a URL like `http://92.168.1.3:8123//auth/authorize` which errors with a status code of 404.
2021-11-14 22:46:12 +00:00
Zac West
c55e1f98ed
Provide clearer error if mobile_app is not loaded during onboarding (#1914)
## Summary
If the API call to `mobile_app/registrations` fails due to a 404, explain that the component needs to be loaded. This likely, in the old flow, was erroring a bit more randomly on the final screen, as the same order of checks was happening.

## Screenshots
| Before | After |
| ------ | ----- |
| ![image](https://user-images.githubusercontent.com/74188/141503139-e09bf4fb-fafb-4743-ad14-34cd9c1bc923.png) | ![image](https://user-images.githubusercontent.com/74188/141503061-7712615f-21fd-45b9-8a83-8ddc67bb6721.png) |

## Any other notes
This is the "Alamofire.AFError 9" error during onboarding _after_ logging in noted in [this forum post](https://community.home-assistant.io/t/ha-companion-app-alamofire-aferror-9/355504/11).

It is worth noting that this error message could be happening because the internal URL (or the URL connecting to) is incorrect, which would produce the same error message after entering the URL or tapping the discovered row, but before entering credentials.
2021-11-13 14:12:21 -08:00
Zac West
b0a0c696a8
Fix infinite loop in onboarding due to internal URL override (#1912)
Fixes a crash where activeURL stack overflows itself when overriding active URL type without sufficient location privacy permission.

## Summary
Pulls the ConnectionInfo activeURL changes from multi-server back to 2021.11.

## 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. -->
2021-11-11 19:25:32 -08:00
Zac West
4c39d8672d
Add testing to onboarding authentication/login handling (#1888) 2021-10-25 21:04:05 -07:00
Zac West
b053654829
Update to Xcode 13.1, add macOS 12 features (#1892)
* Update to Xcode 13.1, add macOS 12 features

* Settings check update

* Swap to Eureka fork which compiles

* Fix pushing twice during notification permission
2021-10-21 06:11:33 +00:00
Zac West
cea0b16936
Update dependencies (#1883)
- Updates several dependencies
- Removes Lokalise -- if we can't do it on Catalyst, it doesn't feel worth it to do it elsewhere
- Migrates the NotificationTestCases from a Podspec that keeps having issues to a fastlane script which copies in the latest ones
2021-10-16 15:19:41 -07:00
Zac West
37c18f59d0
Onboarding visual/flow updates; require permission prompting (#1878)
Fixes #380. Fixes #1794. Fixes #350. Fixes #722.

## Summary
- Pulls all of the onboarding steps out of segue-based storyboards and into code.
- Merges authentication with scanning/manual, reducing steps in auth.
- Removes the "checklist" final screen.
- Supports going 'back' through onboarding steps, e.g. an error after entering a URL.
- Moves permissions from an opt-in "which would you like?" to a required "you must accept/decline this permission" for each permission. See notes below for why.
- Removes the team migration warning from last year.
- Adds landscape & dynamic type support to onboarding. I didn't bother to make the DT do live-updating though.
- Fills in internal & external URL, sets active SSID if possible after location permission.
- Connects to internal URL from discovery instead of base (external) URL.
- Allows onboarding to a server which requests, but does not require, client certificates.
- Allows starting Onboarding skipping the Welcome screen, connects this to the 'add server' row in app configuration when in debug mode.
- Stops calling api/discovery_info for testing connectivity.
- Handles Bonjour updates and removals in the scanning screen.

## Any other notes
Apple is actively blocking 2021.10 (only on iOS) because of an unwritten part of [rule 5.1.1](https://developer.apple.com/app-store/review/guidelines/#5.1.1), saying:

> **Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage**
> 
> We noticed your app encourages or directs users to allow the app to access the location. Specifically, your app directs the user to grant permission in the following way(s):
>
> - A message appears before the permission request, and the user can close the message and delay the permission request with the "Continue" button. The user should always proceed to the permission request after the message.
> 
> Permission requests give users control of their personal information. It is important to respect their decision about how their data is used.

This is of course referring to our screen which looks like this:

<img width="200" src="https://user-images.githubusercontent.com/74188/136716566-349558d4-d343-4ede-acd6-83b4e66742bc.png">

I love that they're cherry-picking the location part of this when we allow users to do a number of things on this screen. I believe the part of 5.1.1 that they are alluding to here is:

> (iv) Access: Apps must respect the user’s permission settings and not attempt to manipulate, trick, or force people to consent to unnecessary data access. For example, apps that include the ability to post photos to a social network must not also require microphone access before allowing the user to upload photos. Where possible, provide alternative solutions for users who don’t grant consent. For example, if a user declines to share Location, offer the ability to manually enter an address.

They do link to the Human Interface Guidelines' [Accessing User Data](https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/accessing-user-data/) whose section "Displaying Custom Messaging Before the Alert" says:

> **Make it clear that opening the system alert is the only action people can take in your custom-messaging screen.** People can interpret a pre-alert message as a delaying tactic, so it’s critical to let them quickly dismiss the message and view the system alert. If you display a custom screen that precedes a privacy-related permission request, it must offer only one action, which must display the system alert. Use a word like "Continue" to title the action; don’t use "Allow" or other terms that might make people think they’re granting their permission or performing other actions within your custom screen.

I do not believe that we're showing a pre-alert message since we're showing numerous options and allowing the user to pick and choose. Oh well. This new onboarding has improvements in other ways, and maybe is _more_ clear about permissions and what they do, so lemons into lemonade I guess.
2021-10-16 05:08:09 +00:00
Zac West
7cbde6ddb2
Try and fix Realm crashes via excessive background tasks (#1874)
Starting in iOS 15, there's a number of crashes happening in the background with Realm. They don't appear to be due to the file lock in the shared app container, but this may help resolve them either way -- easy to see if the next beta doesn't crash a bunch.
2021-10-03 21:28:00 +00:00
Zac West
a2491d632d
Minor fixes for open page widget (#1867)
## Summary
- Fixes e.g. HACS (which is `hacs:hacs`) icons showing the A/B icon. We now fall back to the outline cog.
- Hide panels without the "show in sidebar" option. We get them in the response, but e.g. the title is incorrect.
- Changes sort order in the automatic version to more closely align with the frontend.
- Fixes a case where chosen panels in the past would fail to be updated due to being at the tail end of the array in the API response, due to truncating to widget size _before_ updating.

## Screenshots
![image](https://user-images.githubusercontent.com/74188/135203919-d2951c9a-0bfe-4eb4-8285-a74f9c546882.png)
2021-09-29 04:49:43 +00: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
8041b997b3
Only signal focus sensor updates in the foreground (#1859)
## Summary
Fixes unnecessarily doing a sensor update pass when launching in the background, as well as an occasional crash talking to UIApplication's applicationState off the main thread.

## 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. -->
2021-09-24 19:09:22 -07:00
Zac West
7fa095fdd8
Fix, once again, compiling for Mac (#1849)
## Summary
Once again fixes Mac compilation on the Xcode 13 RC.

## Any other notes
The build failures will continue until morale improves.
2021-09-21 03:45:19 +00:00
Zac West
788567d7e9
Add icons to dynamic notification actions (#1848)
Fixes #1657.

## Summary
Adds the `icon` key to actionable notifications' actions, which must be `sfsymbols:`-prefixed strings of SFSymbols names.

## Screenshots
With a payload that looks like…

```js
{
  /* … */
  "actions": [
    {
      "action": "SOUND_ALARM",
      "title": "Sound Alarm",
      "icon": "sfsymbols:bell",
    },
    {
      "action": "SILENCE_ALARM",
      "title": "Silence Alarm",
      "icon": "sfsymbols:bell.slash",
    }
  ]
}
```

| Dark | Light |
| -- | -- |
| ![image](https://user-images.githubusercontent.com/74188/134095088-554f48e9-fe65-417f-9aa5-59c408299da9.png) | ![image](https://user-images.githubusercontent.com/74188/134095094-debd4625-b60c-4dda-ac92-8ac0f5b44c5e.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#577

## Any other notes
Apple requires that these icons either be pre-baked asset catalog assets, or part of the SFSymbols library (FB9149810), so these are prefixed with `sfsymbols:` to future-proof it.
2021-09-20 19:36:44 -07:00
Zac West
4a3007f0c2
Add live-updating to in-app display of focus sensor (#1845)
## Summary
Fires a sensor update pass if the app is running when the focus status changes.

## Any other notes
The focus sensor _always_ live-updates, but it does so in the Intents extension. This allows the Intents extension to inform the app that it did an update, which (unfortunately, for now) fires a sensor update pass in the app. So we're over-updating the sensors, but we're keeping the in-app sensor list updated. Worth the cost, I think, since the app running when focus changes happening feels rare unless the user's playing with the sensor.
2021-09-19 11:33:36 -07:00
Zac West
a8220f690e
Upgrade MaterialDesignIcons to 6.1.95 (#1844)
## Summary
- Upgrades the font, config, and adds a migration for renamed/removed icons.
- Migrates the one use of a renamed/removed one: `laptop-mac` -> `laptop`

## Any other notes
This change should also make it a little easier to do the migrations, since the Realm+Initialization part won't need to be touched, probably.
2021-09-19 10:36:57 -07:00
Zac West
293fae54cf
Fix focus sensor updating in iOS 15 RC (#1842)
## Summary
Fixes the insta-updating of the focus sensor on iOS 15.

## Any other notes
`INFocusStatusCenter.default.focusStatus` always returns isFocused=false in the extension, but the intent provides the correct focus status for each update -- so we need to cache this value in the extension, and not trust the focus center state.
2021-09-18 20:34:15 -07:00
Zac West
bb53bdd5e5
Xcode 13 (#1841) 2021-09-18 19:42:29 -07:00
Zac West
17fc1898f9
Fix crash updating active sensor idle time setting (#1803)
## Summary
Fixes a crash caused by infinitely recursing the value change.

## Any other notes
This also allows setting fractional minute values, every 15 seconds. The minimum timer which we check is 5 seconds, and that low means we won't detect changes if they occur in a 10 second period which feels too low.
2021-07-19 21:02:56 -07:00
Zac West
b9f043442b
Fix incorrectly entering a <100m zone whose regions intersect a nearby zone (#1695)
Fixes #1693.

## Summary
When we fuzz the coordinate to deal with zone overlap issues in core, we need to also take into account whether we're actually in the zone we'd be fuzzing coordinate to. For zones >=100m, this is the region, but for smaller zones we need to make sure all of the monitored regions agree before changing coordinate.
2021-06-30 23:57:11 -07:00
Zac West
1db6f3cc6e
Local push on iOS (#1656)
Refs #1570 and home-assistant/core#50750. Fixes #1382.

## Summary
Adds a new app extension to do local push notifications on iOS 14 when connected to internal SSIDs.

## Screenshots
Adds a default-on setting to Internal URL:

| Light | Dark |
| -- | -- |
|  ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-19 at 23 13 04](https://user-images.githubusercontent.com/74188/122664142-5cd73d80-d154-11eb-8378-600f0b82b3e4.png) | ![Simulator Screen Shot - iPhone 12 Pro - 2021-06-19 at 23 13 06](https://user-images.githubusercontent.com/74188/122664145-62cd1e80-d154-11eb-840d-0a0e86255bcb.png) |

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

## Any other notes
- Updates the "you need always permission" warning in Internal URL editing to be vibrantly red, to really point out its importance.
- Sets the code signing for the app and the push target to 'manual' on device, hopefully for our internal team only. Special entitlements really do not play well with open source. Worth noting that it is not possible to test this feature without being on the HA team since it does not work in simulator (as far as I can tell) and running on-device requires entitlements.
- Moves commands into Shared in a slightly-easier registration mechanism, so we can share them in the local push extension.
2021-06-20 00:38:57 -07:00
Zac West
cd6fb39c6d
Add "Focus" sensor for iOS 15 & macOS 12 (#1664)
Refs #945. This will not be available until we switch to compiling builds with Xcode 13, regardless of when it is merged.

## Summary
Adds a "Focus" binary sensor which is on when focus is enabled. This updates live, even when the app isn't running, via Intents.

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

## Any other notes
Followup is needed for onboarding to prompt for this permission.
2021-06-18 12:45:09 -07:00
Zac West
50505d1a91
Bump Xcode and dependencies (#1660) 2021-06-17 18:35:55 -07:00
Zac West
0bb4317e7d
Improve handling around refresh token errors (#1661)
Resolves #1542.

## Summary
Logs the error code we get when refreshing a token and log out if we encounter a 403 during token refresh.

## Any other notes
- Fixes an auth handling issue where the WebSocket connection doesn't connect initially.
- Logs out when we encounter a 403 during token refresh. Only a few auth providers do this; specifically, the `trusted_networks` one will reject token refreshes for auth tokens it vends when not on the trusted network. Otherwise, we'll keep retrying and end up getting banned (if enabled).
- Includes the error that we get into the event log so we can trace back the failure easily.
2021-06-10 22:46:17 -07:00
Zac West
7bc64d79a0
Fix events not firing from watch dynamic notification actions (#1618)
Fixes #1604.

## Summary
Dynamic actions -- unlike category-based -- appear to never forward their action handling to the iOS app, despite what the documentation says. Adds tooling to do call it manually.

## Any other notes
Not setting the notification delegate doesn't resolve this, either -- it doesn't appear we're doing anything unexpected, this is just an undocumented/rarely-used area, I guess.
2021-05-02 18:09:24 -07:00
Zac West
119f37c502
Bump dependencies, stop compiling Firebase in CI (#1601)
* Bump dependencies, stop compiling Firebase in CI
* Disallow partial key matches for Pods cache
2021-04-25 11:54:36 -07:00
Zac West
1b88de68a6
Dynamic, per-notification actions (#1588)
Depends on home-assistant/mobile-apps-fcm-push#47 which allows the actions to be included in the notification data, and also on-the-fly silently sets the category to `DYNAMIC` which this requires.

## Summary
Allows for specifying the actions for a notification on-the-fly without defining a category. This should allow us to make all of the category config and setup unnecessary, so I'll probably consider marking it as deprecated in this release.

## Screenshots

For a notification that looks like…

```yaml
service: notify.mobile_app_iphone
data:
  title: title here
  message: body here
  data: 
    actions:
    - action: "id1"
      title: "id1 title"
      # this mirrors the action definition in yaml now, it just _also_ supports what android 
    - identifier: "id2"
      title: "id2 title"
```

![Simulator Screen Shot - Apple Watch Series 6 - 40mm - 2021-04-17 at 20 54 33](https://user-images.githubusercontent.com/74188/115135570-5b5f8c80-9fce-11eb-9118-0d156578d9e5.png)
![Simulator Screen Shot - iPhone 12 Pro - 2021-04-17 at 22 41 07](https://user-images.githubusercontent.com/74188/115135572-60bcd700-9fce-11eb-81b6-c908da8e204c.png)

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

## Any other notes
- Dynamic actions are visual - we provide custom UI on both iOS and watchOS for the additional actions, which does require we run the app on the given platform; for example, this doesn't yet work on macOS [I need to figure out how to make Catalyst notification content work, if it is] and if you uninstall the watch app these actions will not show up.
- Allows `map` and `camera`-esque notification content on any category. In other words, if you send a notification with `map` it'll still prefer the camera `entity_id` if present. This is largely to continue in the direction of making category deprecated; as long as the content extension launches, it'll figure out what to display.

All of the normal action configuration is allowed in these actions:
- action or identifier
- title
- authenticationRequired (default: false)
- behavior (default: default, aka not textinput)
- activationMode (default: background)
- destructive (default: false)
- textInputButtonTitle (default: nil)
- textInputPlaceholder (default: nil)

Some additional things occur to match existing Android functionality:
- `uri` (or `url`) being provided in the action makes it a 'foreground' action
- action/identifier of `REPLY` changes the behavior to textinput
- `mobile_app_notification_action` is now fired with data that looks like theirs:

```
Sending action: mobile_app_notification_action
payload: ["action": "REPLY", "reply_text": "Reply text"]
```

and

```
Sending action: mobile_app_notification_action
payload: ["action": "id1"]
```
2021-04-19 04:28:39 +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
90fa3ea022
Limit Sentry breadcrumbs to warning & reduce some logs (#1568)
* Limit Sentry breadcrumbs to warning level or above

* Reduce some logging
2021-04-03 11:56:11 -07:00
Zac West
f74726916e
Remove global-ish token manager (#1566) 2021-04-03 10:59:20 -07:00
Zac West
da2574a3b5
Cache date formatter for frontmost app sensor (#1567)
Since we change the settings on the formatter, we end up paying initialization cost for each one, which adds up fast when command-tabbing.
2021-04-03 10:58:47 -07:00
Zac West
6a0c565030
Reduce how often performing an action is retried (#1564)
Fixes #1552.

## Summary
Only fires on the watch if sending via phone is not an option, and only allows ephemerally sending an action.

## Any other notes
Ephemerally sending doesn't retry nearly as much, and doesn't enter into any background URL session for possible persistent retry.
2021-04-03 03:49:32 +00:00
Zac West
7eb8f692dc
Move render template (non-complication) to WebSocket API (#1556)
## Summary
Moves over the directly-render templates. Complications can never be moved over because they need to work cleanly with the background session logic on the watch.

## Any other notes
Slightly poorly ergonomic about subscribing and then cancelling; might be nice to provide a "send this subscription and unsubscribe after the first event" flag, but nothing great for how to do that comes to mind.
2021-03-28 16:08:42 -07:00
Zac West
a1190f953c
Move REST-based state getting into WebSocket API (#1536)
## Summary
- Moves a few uses of `states` in the REST API into the WebSocket API.
- Zones and Scenes now update instantly as we're updated via the WebSocket subscription.

## Any other notes
- Moves the account row in Settings to be fully self-contained on user and avatar lookup, both through the same WebSocket API call for finding out what to show.
- Moves zone fetching's `get_zones` WebHook call into the WebSocket API cache for `get_states`.
- Moves scene's fetching `get_states` into the same WebSocket API cache.
- Moves Camera ID intents lookup.
2021-03-21 19:03:08 -07:00
Zac West
7e598ff9f9
Move "Get Services" into WebSocket API (#1535)
## Summary
Moves the one instance of this call (Intents) to using the WebSocket API.

## Any other notes
- Updates to use the new PromiseKit extensions and automatic connection handling in HAKit.
- Removes now-unused models for Services and already-unused Events.
2021-03-13 12:14:39 -08:00
Zac West
eef46b3249
Improve the location history screens (#1525)
## Summary
Adds more detail to the list and reshuffles detail to include up/down buttons to move through entries.

## Screenshots
<img width="350" src="https://user-images.githubusercontent.com/74188/110901125-ad6b0f00-82b8-11eb-9575-f0437e8bb313.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110901132-af34d280-82b8-11eb-947f-4b967e7f38fe.png">
<img width="350" src="https://user-images.githubusercontent.com/74188/110898692-8f031480-82b4-11eb-9d51-61664224758e.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110898697-90ccd800-82b4-11eb-9403-d3ae7038d5cd.png">

## Any other notes
This also adds more information to the debug file shared and improves the selected state handling in the list.
2021-03-12 06:39:30 +00:00
Zac West
5c132da07f
Add "Location History" to Settings (#1521)
## Summary
Hopefully improve debugging location issues by providing a visualization of what we know about a location update.

## Screenshots
<img width="350" src="https://user-images.githubusercontent.com/74188/110420951-5ca5ad00-8051-11eb-82d9-b81dc28e20b7.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110420954-5dd6da00-8051-11eb-9d78-61783873b08a.png">
<img width="350" src="https://user-images.githubusercontent.com/74188/110420959-60393400-8051-11eb-906c-74e19096e274.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110420961-616a6100-8051-11eb-9aee-334234a6c59c.png">
<img width="350" src="https://user-images.githubusercontent.com/74188/110420972-63ccbb00-8051-11eb-855c-4e7d41a4e16f.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110420975-64fde800-8051-11eb-9876-c0cb0f682727.png">
<img width="350" src="https://user-images.githubusercontent.com/74188/110420986-692a0580-8051-11eb-976b-1e2be659bcae.png"><img width="350" src="https://user-images.githubusercontent.com/74188/110420988-6af3c900-8051-11eb-982c-aaa903f4af5d.png">

## Any other notes
- Shows a blue circle for zones, an orange circle for non-single-region zones' regions, a purple circle for location and its accuracy.
- Allows sharing a bunch of debug data about the location and region states.
- Allows clearing of location history.
2021-03-08 22:57:49 -08:00
Zac West
c4769f7b97
Add WebSocket API connecting and status (#1512)
## Summary
Adds [HAKit](https://github.com/home-assistant/HAKit) to connect to the WebSocket API.

## Any other notes
Currently not used for anything other than showing the status of its connection.
2021-03-06 19:39:06 -08:00
Jiri Urbasek
5e66b28e69
Add API request to get logbook entries for current day (#1481) 2021-02-16 23:05:13 -08:00
Zac West
bcc007fdb9
Fix incorrectly cancelling ephemeral tasks (#1489)
Fixes regression in #1487.

## Summary
Ephemeral webhook sends do not have any persisted info on them, and that's to be expected.

## Any other notes
None.
2021-02-16 07:23:13 +00:00
Zac West
ae1d3ac4a0
Fix non-background-session webhook request replacement (#1487)
Fixes #1473. Again.

## Summary
When we issue webhook requests, we were failing to cancel any previous requests (which want to be cancelled) that were executed on not-the-background session. This moves to now checking both the background and non-background for cancellable requests.

## Any other notes
- Moves to explicitly cancelling, rather than silently replacing and succeeding, replaced requests. For example, a sensor update will now be explicitly cancelled if a new sensor update comes through, rather than following the success path.
- This resolves an issue where a sensor update occurs, fails on the non-background session, and retries with the same request data on the background session. This can lead to an older sensor update request, with outdated information, happening long after the most recent and correct one finishing.
2021-02-15 16:47:01 -08:00
Zac West
86b0b0a409
Allow disabling individual sensors (#1484)
Fixes #358.

## Summary
Allows toggling on or off certain sensors. This does not currently delete the sensor but instead sets its state to 'unavailable'.

## Screenshots
### App
![Image](https://user-images.githubusercontent.com/74188/107861269-bd96e800-6df9-11eb-93c4-682eab17b157.png)
![Image 2](https://user-images.githubusercontent.com/74188/107861298-d8695c80-6df9-11eb-9496-dc89cdc892c0.png)

### Frontend
<img width="334" alt="entities" src="https://user-images.githubusercontent.com/74188/107861381-5c234900-6dfa-11eb-86c5-27b7f6ea2c2e.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
- Sensors are still only showing up in the sensor list if they have been generated during the app lifecycle. So for example the Geocode sensor doesn't show up unless a location update happened, and motion sensors do not show up if motion permission is disabled.
- Avoids removing items from the cache when they aren't around anymore, or when we think they are stale.
2021-02-13 16:55:16 -08:00
Zac West
37e5080118
Fix an out-of-order sensor caching issue (#1477)
Fixes #1473.
Refs #1460/#1467.

## Summary
When an earlier request gets applied later than we expect, we also need to assume it has replaced values similar to the transient update case fixed before.

## Any other notes
I am going to keep telling myself that the long-term benefit of the sensor caching outweighs having to figure out all of these real-world edge cases the hard way. In this case, I already expected it, I just did not fully think through the ramifications of the edge case and how it would look from the server perspective.
2021-02-11 19:35:43 -08:00
Zac West
bcb307a7dd
Fix not updating sensors when prior update fails for transient value change (#1467)
Fixes #1460.

## Summary
Fixes our internal cache being out of sync with the sensor values on the server.

## Any other notes
This issue occurs when, for example, we transition from value1 -> value2 -> value1. If the value2 update fails from our perspective, but successfully hits the server, we may not realize that we need to send value1 up again in the future.
2021-02-06 18:04:29 -08:00