Skip to content

Commit c5b9cae

Browse files
authored
Improve logs for entities model updater (home-assistant#3283)
<!-- 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. -->
1 parent a9e6896 commit c5b9cae

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Sources/Shared/API/Models/AppEntitiesModel.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ final class AppEntitiesModel: AppEntitiesModelProtocol {
103103
} catch {
104104
Current.Log.error("Failed to get cache for App Entities, error: \(error.localizedDescription)")
105105
Current.clientEventStore.addEvent(ClientEvent(
106-
text: "Updated database App Entities for \(server.info.name)",
106+
text: "Update database App Entities FAILED for \(server.info.name)",
107107
type: .database,
108-
payload: ["entities_count": appEntities.count]
108+
payload: ["error": error.localizedDescription]
109109
)).cauterize()
110110
}
111111
}

Sources/Shared/Environment/PeriodicAppEntitiesModelUpdater.swift

+22-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ final class PeriodicAppEntitiesModelUpdater: PeriodicAppEntitiesModelUpdaterProt
3737
Current.appEntitiesModel().updateModel(Set(entities), server: server)
3838
case let .failure(error):
3939
Current.Log.error("Failed to fetch states: \(error)")
40+
Current.clientEventStore.addEvent(.init(
41+
text: "Failed to fetch states on server \(server.info.name)",
42+
type: .networkRequest,
43+
payload: [
44+
"error": error.localizedDescription,
45+
]
46+
)).cauterize()
4047
}
4148
}
4249
)
@@ -50,7 +57,14 @@ final class PeriodicAppEntitiesModelUpdater: PeriodicAppEntitiesModelUpdaterProt
5057
case let .success(response):
5158
self?.saveEntityRegistryListForDisplay(response, serverId: server.identifier.rawValue)
5259
case let .failure(error):
53-
Current.Log.error("Failed to fetch states: \(error)")
60+
Current.Log.error("Failed to fetch EntityRegistryListForDisplay: \(error)")
61+
Current.clientEventStore.addEvent(.init(
62+
text: "Failed to fetch EntityRegistryListForDisplay on server \(server.info.name)",
63+
type: .networkRequest,
64+
payload: [
65+
"error": error.localizedDescription,
66+
]
67+
)).cauterize()
5468
}
5569
}
5670
)
@@ -80,6 +94,13 @@ final class PeriodicAppEntitiesModelUpdater: PeriodicAppEntitiesModelUpdaterProt
8094
} catch {
8195
Current.Log
8296
.error("Failed to save EntityRegistryListForDisplay in database, error: \(error.localizedDescription)")
97+
Current.clientEventStore.addEvent(.init(
98+
text: "Failed to save EntityRegistryListForDisplay in database, error on serverId \(serverId)",
99+
type: .database,
100+
payload: [
101+
"error": error.localizedDescription,
102+
]
103+
)).cauterize()
83104
}
84105
}
85106

0 commit comments

Comments
 (0)