Commit Graph

24 Commits

Author SHA1 Message Date
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
64839bbac5 Move background task keys to enum and add tests (#3673)
<!-- 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>
2025-06-25 15:03:30 +02:00
Bruno Pantaleão Gonçalves
02e5fa6692 Save ClientEvents on local json file instead of GRDB to avoid crashes (#3378) 2025-01-30 12:55:32 +01:00
Bruno Pantaleão Gonçalves
30bd140716 Increase "location too old" time (#3227)
<!-- 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. -->
2024-12-03 15:35:56 +01:00
Bruno Pantaleão Gonçalves
13ac4e4a87 Making API connection optional given activeURL is now optional as well (#3169)
<!-- 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. -->
2024-11-18 15:07:18 +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
David Beitey
7c052a9f1d Update repo name and URL in CONTRIBUTING docs (#2210)
<!-- 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 clarifies in the contributing docs which project is being
contributed to and which repo to work against - previously it said just
"Home Assistant" which could be confusing.

This also updates the repo URL in the contributing docs and at the same
time several code comments that also used the older repo URL.

## 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. -->
2022-09-30 16:27:39 +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
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
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
55c43b9fc0 Log about accuracy/coordinate fuzzing when occurring (#1694)
Refs #1693. I'm pretty sure it's not fuzzing location or accuracy in these cases, but I can't be 100% sure.

## Summary
Hopefully makes some location things easier to see when looking at logs.
2021-06-30 09:58:45 -07:00
Zac West
90ed5be5fc Fixes zone enter with multiple overlapping zones where core ignores accuracy (#1641)
Fixes #1627.

## Summary
When a GPS coordinate is outside the zone, even if accuracy places it inside, the logic in core will prefer a zone which contains the exact coordinates, regardless of accuracy. This moves the coordinate over to be inside the zone.

## Any other notes
- Allows fuzzers to change coordinate, even though we really do not want to do this. This is effectively fudging the real location data, which is something I've avoided as much as possible to this point.
- Adds a helper method to determine bearing to another location so that we know how to adjust the position towards the center of the zone.
2021-05-15 12:30:43 -07:00
Zac West
da01facfbb Fix location change overriding recent region changes (#1640)
Fixes #1620.

## Summary
Prevents doing a location update just after a region event -- within 30 seconds. Region events may have accuracy fuzzing which the significant location change wouldn't know about, so it would override the fuzz. Region events are never prevented.

## Any other notes
This also makes processor events queue up rather than all executing simultaneously, both so we can make sure we don't do this error case and so we don't have other weird state transitions that I can't think of.
2021-05-14 19:51:37 -07:00
Zac West
982ddd0325 Fix another sub-100m zone fuzzed accuracy enter issue (#1575)
## Summary
When the accuracy is fuzzed based on a region enter, we need to use that fuzzed location for the next fuzzer.

## Any other notes
To make it less easy to make this bug happen again (where the intermediary fuzz value is ignored), this moves them to be reducing the same variable in a row.

Also fixed the test case for this flow to explicitly have this double-up requirement.
2021-04-07 02:00:20 +00:00
Zac West
beb10111c7 Fix a sub-100m zone stuck-outside issue & a iOS pre-13.4 issue (#1524)
Fixes #1520.

## Summary
Fixes a case where entering the 3-region overlap with extremely good accuracy wouldn't trigger an update to inside the zone. Also fixes not using the fuzzed accuracy at all on older than iOS 13.4.
2021-03-11 18:51:40 -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
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
c6167742f2 Revert PromiseKit threading change (#1431)
- Reverts #1418 - there's enough logic that is relying on the single-threadedness of then/map-ing on a shared queue.
- Forces all `Current.api` access to be done not on a queue intentionally, to avoid thread jumping when we don't expect, which is the core crash that this was trying to fix.
2021-01-26 21:11:53 -08:00
Zac West
5b75b2ea4c Move API access into Environment (#1390)
Consolidates REST API access into one entry point, ish.
2021-01-21 20:45:42 -08:00
Zac West
8d6f78e954 Fix infinite loop when monitoring regions when exceeding maximums (#1286)
At least on iOS 13 and 14, initially monitoring a region causes the system to always fire a did-change-state delegate method for that zone. When users exceed the 20 region threshold, the delegate firing can cause us to bounce back and forth between sets of zones that we want to monitor, and each chain can cause another set of updates to occur. This is especially apparent for users using the iCloud3 integration which creates a multitude of 1m zones.

Fixes #1267
2020-11-20 13:11:32 -08:00
Zac West
6a797a6f33 Resolve minor debug logging and try! crashes (#1235)
- NSLog is dangerous in production; it crashes randomly on iOS 13. It also truncates the logs to a certain length, unlike print(), so swap to that one.
- This also changes a few try! into not-force-unwrapping, one or two of which have fired into the crash reporter.
- Avoids logging about deleted zones while they are being deleted. Likely related to the infinite-loop zone (#1136) but definitely happens quite a bit right now.
2020-10-24 10:01:05 -07:00
Zac West
77c72785ff Update a few more housekeeping things in the project (#1142)
- Combines all .entitlements into either: App-iOS, App-catalyst, WatchApp, Extension-iOS or Extension-catalyst.
- Cleans up and renames all the schemes to match target names
- Moves around several folders and deletes some old files.
- Converts Podfile to be hierarchical, rather than calling shared methods.
- Always runs MaterialDesignIcons script; aborts early if it's up-to-date.
- Updates all dependencies.
2020-10-03 16:05:19 -07:00