I got excited for the companion app 2.0 when I saw it available in the app store, so as I usually do when new things come out that have the potential to break my otherwise perfectly working setup I attempted to install the app on an old iphone 5 running iOS10. I could not get it setup, due to what I thought was running an old version of Home assistant (0.91). I spent the weekend upgrading HA to the latest version .104.3 and fixing all the things that going 15 versions up caused. Those are all worked out however the mobile app is still not working. The first thing I did was: follow these steps: https://companion.home-assistant.io/en/troubleshooting/beta-cleaning
- Uninstalling the app
- Deleting the Mobile App integrations from Configuration -> Integrations section
- Deleting the mobile_app file in the .storage folder
- Restarting HA
I then re-downloaded the mobile app and went though the setup on the app again. I get all the way through setup, successfully log in, and get to the ‘Loading Data’ screen. It sits there for a few seconds then displays ‘Unable to connect to home assistant’ with a retry button.
Here is what I think is the offending line from the HA log
2020-01-26 16:44:59 ERROR (SyncWorker_18) [homeassistant.util.json] Saving JSON file failed: [Redacted]\.storage\mobile_app
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\homeassistant\util\json.py", line 66, in save_json
os.replace(tmp_filename, filename)
PermissionError: [WinError 5] Access is denied: '[Redacted]\\.storage\\tmpou4z83dm' -> '[Redacted]\\homeassistantConfig\\.storage\\mobile_app'
2020-01-26 16:44:59 ERROR (MainThread) [homeassistant.helpers.storage] Error writing config for mobile_app: [WinError 5] Access is denied: '[Redacted]\\.storage\\tmpou4z83dm' -> '[Redacted]\\.storage\\mobile_app'
I have also attempted to run homeassistant via an elevated cmd window, however I got the same error message in the log.
This error was generated after I went though the configuration of the mobile app (remember I deleted the mobile_app file before starting this process, however a new mobile_app file appeared at some point, which leads me to believe that HA has permission to write to the .storage folder, or this could be red herring. My other devices running the old mobile app have no problems connecting to my home assistant server, receiving notifications, and sending their location. So there is something going on with the new mobile app.
HA is running on Windows Server 2016 accessible to the internet via https port 443 using a CA signed cert from Lets Encrypt
Additionally here is the exported log from the app:
2020-01-26 16:43:48.039 [Info] > Home Assistant Version: 2.0.0 Build: 69 PID: 431
2020-01-26 16:43:48.039 [Info] > XCGLogger Version: 7.0.0 - Level: Debug
2020-01-26 16:43:48.056 [Info] > XCGLogger writing log to: file:///private/var/mobile/Containers/Shared/AppGroup/99D0346B-FD48-4121-816B-27357C9CE398/logs/log.txt
2020-01-26 16:43:48.063 [Verbose] [main] [AppDelegate.swift:701] setupFirebase() > Setting up Firebase with plist at path: /var/containers/Bundle/Application/E4190B2A-F8B2-425F-97D5-83D454540EA7/Home Assistant.app/GoogleService-Info-Release.plist
2020-01-26 16:43:48.215 [Warning] [main] [Environment.swift:158] loadCrashlytics() > Enabling Firebase Crashlytics!
2020-01-26 16:43:48.666 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:43:48 +0000;
text = Application Starting;
typeString = unknown;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:43:48.716 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:43:48 +0000;
text = Initializing Region Manager;
typeString = unknown;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:43:48.822 [Verbose] [main] [Notifications.swift:32] ProvideNotificationCategoriesToSystem() > Providing 0 categories to system: []
2020-01-26 16:43:49.020 [Verbose] [NSOperationQueue 0x180c6e50 :: NSOperation 0x16ff3970 (QOS: UTILITY)] [AppDelegate.swift:479] setupWatchCommunicator() > Activation state changed: activated
2020-01-26 16:43:49.023 [Warning] [NSOperationQueue 0x180c6e50 :: NSOperation 0x16ff3970 (QOS: UTILITY)] [WatchHelpers.swift:62] SyncWatchContext() > Tried to sync HAAPI config to watch but watch not paired or app not installed
2020-01-26 16:43:50.461 [Verbose] [main] [WelcomeViewController.swift:74] reachabilityChanged(_:) > Reachability changed to WiFi
2020-01-26 16:43:52.761 [Verbose] [main] [Bonjour.swift:22] netServiceBrowser(_:didFind:moreComing:) > BonjourDelegate.Browser.didFindService
2020-01-26 16:43:52.773 [Info] [main] [AppDelegate.swift:152] applicationDidBecomeActive(_:) > Lokalise updated? true
2020-01-26 16:43:53.059 [Verbose] [main] [Bonjour.swift:29] netServiceDidResolveAddress(_:) > BonjourDelegate.Browser.netServiceDidResolveAddress
2020-01-26 16:43:53.204 [Info] [main] [AppDelegate.swift:882] messaging(_:didReceiveRegistrationToken:) > Firebase registration token refreshed, new token: dYlhmEPvifU:APA91bFaxTddKnd9Yf6HimYo4EEtB-Nyg5_v5wRDVmSwLQxhZQRg2-a3Rbc1GESx8J8lMta3X8ehwTkdI9rYuEbUFqx66gYYwNTkjCG8KRH82dTN9_62PYYQ-17gTNEXVe43T5abHedA
2020-01-26 16:43:53.326 [Error] [main] [HAAPI+WebhookHelpers.swift:31] handleWebhookResponse(response:seal:callingFunctionName:) > Error on updateRegistration request: Error Domain=com.alamofireobjectmapper.error Code=2 "ObjectMapper failed to serialize response." UserInfo={NSLocalizedFailureReason=ObjectMapper failed to serialize response.}
2020-01-26 16:43:58.130 [Verbose] [main] [ChooseDiscoveredInstanceViewController.swift:31] viewDidLoad() > Received instances [Shared.DiscoveredHomeAssistant]
2020-01-26 16:44:14.777 [Verbose] [main] [ChooseDiscoveredInstanceViewController.swift:51] tableView(_:didSelectRowAt:) > Selected row at 0 Optional(Shared.DiscoveredHomeAssistant)
2020-01-26 16:44:15.471 [Verbose] [NSOperationQueue 0x183b94b0 :: NSOperation 0x18207d40 (QOS: DEFAULT)] [AuthenticationViewController.swift:149] testConnection(_:) > Handling challenge NSURLAuthenticationMethodServerTrust
2020-01-26 16:44:15.472 [Verbose] [NSOperationQueue 0x183b94b0 :: NSOperation 0x18207d40 (QOS: DEFAULT)] [AuthenticationViewController.swift:151] testConnection(_:) > Allowing challenge NSURLAuthenticationMethodServerTrust
2020-01-26 16:44:15.569 [Verbose] [main] [AuthenticationViewController.swift:167] testConnection(_:) > Request: Optional()
2020-01-26 16:44:15.570 [Verbose] [main] [AuthenticationViewController.swift:168] testConnection(_:) > Response: Optional(<NSHTTPURLResponse: 0x180d5c20> { URL: } { status code: 200, headers {
"Content-Encoding" = gzip;
"Content-Length" = 127;
"Content-Type" = "application/json";
Date = "Sun, 26 Jan 2020 23:44:15 GMT";
Server = "Python/3.7 aiohttp/3.6.1";
} })
2020-01-26 16:44:15.571 [Verbose] [main] [AuthenticationViewController.swift:169] testConnection(_:) > Result: SUCCESS
2020-01-26 16:44:15.572 [Error] [main] [AuthenticationViewController.swift:170] testConnection(_:) > Error: nil
2020-01-26 16:44:15.618 [Verbose] [main] [AuthenticationViewController.swift:67] viewDidLoad() > URL resolves to internal? false
2020-01-26 16:44:18.223 [Verbose] [main] [AuthenticationViewController.swift:113] connectButtonTapped(_:) > Attempting browser auth to:
2020-01-26 16:44:39.038 [Verbose] [main] [AppDelegate.swift:245] application(_:open:options:) > Received URL: homeassistant://auth-callback?code=d47fa55dacce41e9a71db6454071a2cb
2020-01-26 16:44:39.041 [Verbose] [main] [AuthenticationController.swift:166] handleSuccess(_:) > Returning from authentication with code d47fa55dacce41e9a71db6454071a2cb
2020-01-26 16:44:39.043 [Verbose] [main] [AuthenticationViewController.swift:117] connectButtonTapped(_:) > Browser auth succeeded, getting token
2020-01-26 16:44:39.133 [Verbose] [main] [AuthenticationViewController.swift:120] connectButtonTapped(_:) > Got token info TokenInfo(accessToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJlMGM1YWQwMzc2NWI0MDgyYWNjYjY0ZmJkMGJjOWNiMyIsImlhdCI6MTU4MDA4MjI3OSwiZXhwIjoxNTgwMDg0MDc5fQ.KMNh9vlt48m08uNxTvr4ChVmzZxcSvd672XlMwCRrJ4", expiration: 2020-01-27 00:14:39 +0000, refreshToken: "e0da53b6228158c8fb3a31eafd36d8ac6cee0dabac6280a1e36244386417b32999d3c3c1a299faf23ae6ad56bbe2c68a7072b4cfdc28bfb6a530bb6521f1d29c")
2020-01-26 16:44:39.195 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:39 +0000;
text = [External URL]/api/config;
typeString = networkRequest;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:43.872 [Verbose] [main] [ConnectionInfo.swift:372] adapt(_:_:) > Changing request URL /2e8f314c41f498f087fff7af3618492e9b5bb7bbb987affd8a1e69ee5de8c4c9 to
2020-01-26 16:44:43.953 [Verbose] [main] [PermissionsViewController.swift:43] statusChanged(_:_:) > Permission Location status changed to Authorized
2020-01-26 16:44:44.017 [Verbose] [main] [RegionManager.swift:243] locationManager(_:didUpdateLocations:) > didUpdateLocations [<+33.66101188,-111.99602293> +/- 1000.00m (speed -1.00 mps / course -1.00) @ 1/24/20, 8:56:56 PM Mountain Standard Time]
2020-01-26 16:44:44.036 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:44 +0000;
text = Ignoring location with accuracy over threshold.Accuracy: 1000.0m;
typeString = locationUpdate;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:44.299 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x180eb9e0 (QOS: DEFAULT)] [ConnectionInfo.swift:393] should(_:retry:with:) > isRemoteUIFailure false
2020-01-26 16:44:44.299 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x180eb9e0 (QOS: DEFAULT)] [ConnectionInfo.swift:397] should(_:retry:with:) > isInternalURLFailure false
2020-01-26 16:44:44.300 [Warning] [NSOperationQueue 0x180d0b70 :: NSOperation 0x180eb9e0 (QOS: DEFAULT)] [ConnectionInfo.swift:419] should(_:retry:with:) > Not retrying a failure other than remote UI down or internal URL no longer valid
2020-01-26 16:44:45.413 [Verbose] [main] [ConnectionInfo.swift:372] adapt(_:_:) > Changing request URL /2e8f314c41f498f087fff7af3618492e9b5bb7bbb987affd8a1e69ee5de8c4c9 to
2020-01-26 16:44:45.501 [Verbose] [main] [PermissionsViewController.swift:43] statusChanged(_:_:) > Permission Motion & Pedometer status changed to Authorized
2020-01-26 16:44:45.559 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18222770 (QOS: DEFAULT)] [ConnectionInfo.swift:393] should(_:retry:with:) > isRemoteUIFailure false
2020-01-26 16:44:45.560 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18222770 (QOS: DEFAULT)] [ConnectionInfo.swift:397] should(_:retry:with:) > isInternalURLFailure false
2020-01-26 16:44:45.564 [Warning] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18222770 (QOS: DEFAULT)] [ConnectionInfo.swift:419] should(_:retry:with:) > Not retrying a failure other than remote UI down or internal URL no longer valid
2020-01-26 16:44:46.896 [Verbose] [main] [ConnectionInfo.swift:372] adapt(_:_:) > Changing request URL /2e8f314c41f498f087fff7af3618492e9b5bb7bbb987affd8a1e69ee5de8c4c9 to
2020-01-26 16:44:47.046 [Verbose] [main] [PermissionsViewController.swift:43] statusChanged(_:_:) > Permission Notifications status changed to Authorized
2020-01-26 16:44:47.165 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18107c70 (QOS: DEFAULT)] [ConnectionInfo.swift:393] should(_:retry:with:) > isRemoteUIFailure false
2020-01-26 16:44:47.166 [Verbose] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18107c70 (QOS: DEFAULT)] [ConnectionInfo.swift:397] should(_:retry:with:) > isInternalURLFailure false
2020-01-26 16:44:47.167 [Warning] [NSOperationQueue 0x180d0b70 :: NSOperation 0x18107c70 (QOS: DEFAULT)] [ConnectionInfo.swift:419] should(_:retry:with:) > Not retrying a failure other than remote UI down or internal URL no longer valid
2020-01-26 16:44:47.213 [Verbose] [main] [AppDelegate.swift:165] application(_:didRegisterForRemoteNotificationsWithDeviceToken:) > Successfully registered for push notifications! APNS token: c29abf0dff07fdc939e5a18afb67765cdc9e1239459c80f2422e3d73cd2036a1
2020-01-26 16:44:50.010 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:49 +0000;
text = [External URL]/api/mobile_app/registrations;
typeString = networkRequest;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:51.717 [Verbose] [main] [HAAPI.swift:328] Register() > Registration response Shared.MobileAppRegistrationResponse
2020-01-26 16:44:51.788 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:51 +0000;
text = [External URL]/api/config;
typeString = networkRequest;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:51.829 [Warning] [main] [WebhookSensors.swift:292] getLatestMotionActivity() > Activity is not available
2020-01-26 16:44:51.843 [Warning] [main] [WebhookSensors.swift:212] getLatestPedometerData() > Step counting is not available
2020-01-26 16:44:52.003 [Verbose] [main] [HAAPI.swift:619] RegisterSensors(_:) > Registering sensors [Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0), Promise<WebhookSensorResponse>.pending(handlers: 0)]
2020-01-26 16:44:52.225 [Verbose] [main] [RegionManager.swift:188] syncMonitoredRegions() > Starting monitoring of zone RLMZone {
ID = zone.home;
FriendlyName = (null);
Latitude = 33.660979;
Longitude = -111.995818;
Radius = 100;
TrackingEnabled = 1;
enterNotification = 1;
exitNotification = 1;
inRegion = 0;
BeaconUUID = (null);
BeaconMajor = (null);
BeaconMinor = (null);
SSIDTrigger = List<string> <0x1825b1f0> (
);
SSIDFilter = List<string> <0x180d0720> (
);
}
2020-01-26 16:44:52.228 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:52 +0000;
text = Monitoring: Zone - ID: zone.home, state: outside;
typeString = unknown;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:52.241 [Verbose] [main] [ConnectInstanceViewController.swift:58] viewDidLoad() > Done with setup, continuing!
2020-01-26 16:44:52.258 [Verbose] [main] [RegionManager.swift:311] locationManager(_:didStartMonitoringFor:) > didStartMonitoringFor CLCircularRegion (identifier:'zone.home', center:<+33.66097900,-111.99581800>, radius:100.00m)
2020-01-26 16:44:52.269 [Verbose] [main] [RegionManager.swift:316] locationManager(_:didStartMonitoringFor:) > Started monitoring region: CLCircularRegion (identifier:'zone.home', center:<+33.66097900,-111.99581800>, radius:100.00m), zone: RLMZone {
ID = zone.home;
FriendlyName = (null);
Latitude = 33.660979;
Longitude = -111.995818;
Radius = 100;
TrackingEnabled = 1;
enterNotification = 1;
exitNotification = 1;
inRegion = 0;
BeaconUUID = (null);
BeaconMajor = (null);
BeaconMinor = (null);
SSIDTrigger = List<string> <0x184efda0> (
);
SSIDFilter = List<string> <0x1824ebb0> (
);
}
2020-01-26 16:44:52.291 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:52 +0000;
text = Region monitoring failed for region: zone.home. Error: The operation couldn’t be completed. (kCLErrorDomain error 5.);
typeString = locationUpdate;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:52.295 [Error] [main] [RegionManager.swift:307] locationManager(_:monitoringDidFailFor:withError:) > Region monitoring failed: error: Error Domain=kCLErrorDomain Code=5 "(null)", region: Optional(CLCircularRegion (identifier:'zone.home', center:<+33.66097900,-111.99581800>, radius:100.00m))
2020-01-26 16:44:58.524 [Verbose] [main] [ConnectInstanceViewController.swift:66] viewDidLoad() > Dismissing from permissions
2020-01-26 16:44:59.023 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:59 +0000;
text = [External URL]/api/config;
typeString = networkRequest;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:59.074 [Warning] [main] [WebhookSensors.swift:292] getLatestMotionActivity() > Activity is not available
2020-01-26 16:44:59.105 [Warning] [main] [WebhookSensors.swift:212] getLatestPedometerData() > Step counting is not available
2020-01-26 16:44:59.110 [Verbose] [main] [WatchHelpers.swift:85] BuildWatchRenderTemplatePayload() > complications Results<WatchComplication> <0x1824a130> (
)
2020-01-26 16:44:59.112 [Verbose] [main] [WatchHelpers.swift:91] BuildWatchRenderTemplatePayload() > mostRecentlyReceievedContext.content nil []
2020-01-26 16:44:59.112 [Verbose] [main] [WatchHelpers.swift:127] updateComplications() > No complications have templates, not sending the request!
2020-01-26 16:44:59.352 [Info] [main] [ClientEventStore.swift:23] ClientEventStore > ClientEvent {
date = 2020-01-26 23:44:59 +0000;
text = Already Monitoring: Zone - ID: zone.home, state: outside;
typeString = unknown;
jsonData = <(null) — 0 total bytes>;
}
2020-01-26 16:44:59.359 [Verbose] [main] [WebViewController.swift:159] viewDidLoad() > Connected!
2020-01-26 16:44:59.375 [Verbose] [main] [AppDelegate.swift:165] application(_:didRegisterForRemoteNotificationsWithDeviceToken:) > Successfully registered for push notifications! APNS token: c29abf0dff07fdc939e5a18afb67765cdc9e1239459c80f2422e3d73cd2036a1
2020-01-26 16:45:00.590 [Verbose] [main] [WebViewController.swift:584] userContentController(_:didReceive:) > getExternalAuth called
2020-01-26 16:45:01.106 [Verbose] [main] [WebViewController.swift:584] userContentController(_:didReceive:) > getExternalAuth called
2020-01-26 16:45:01.126 [Verbose] [main] [WebViewController.swift:596] userContentController(_:didReceive:) > Success on getExternalAuth callback: nil
2020-01-26 16:45:01.127 [Verbose] [main] [WebViewController.swift:596] userContentController(_:didReceive:) > Success on getExternalAuth callback: nil
2020-01-26 16:45:06.604 [Verbose] [main] [WebViewController.swift:584] userContentController(_:didReceive:) > getExternalAuth called
2020-01-26 16:45:06.615 [Verbose] [main] [WebViewController.swift:584] userContentController(_:didReceive:) > getExternalAuth called
2020-01-26 16:45:06.641 [Verbose] [main] [WebViewController.swift:596] userContentController(_:didReceive:) > Success on getExternalAuth callback: nil
2020-01-26 16:45:06.642 [Verbose] [main] [WebViewController.swift:596] userContentController(_:didReceive:) > Success on getExternalAuth callback: nil
2020-01-26 16:45:41.596 [Verbose] [main] [SettingsViewController.swift:165] viewDidLoad() > Logs directory is: file:///private/var/mobile/Containers/Shared/AppGroup/99D0346B-FD48-4121-816B-27357C9CE398/logs/
2020-01-26 16:45:41.598 [Debug] [main] [SettingsViewController.swift:172] viewDidLoad() > Exporting logs as filename 2020-01-26T164541-0700_logs.zip
Let me know if anyone has any ideas of things to try.