-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache config/entity_registry/list_for_display
- Loading branch information
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Foundation | ||
import GRDB | ||
import HAKit | ||
|
||
public struct EntityRegistryListForDisplay: HADataDecodable { | ||
public let entityCategories: [String: String] | ||
public let entities: [Entity] | ||
|
||
public init(data: HAData) throws { | ||
self.entityCategories = try data.decode("entity_categories") | ||
self.entities = try data.decode("entities") | ||
} | ||
|
||
public struct Entity: HADataDecodable, Codable, FetchableRecord, PersistableRecord { | ||
public let entityId: String | ||
public let entityCategory: Int? | ||
public let decimalPlaces: Int? | ||
|
||
public init(data: HAData) throws { | ||
self.entityId = try data.decode("ei") | ||
self.entityCategory = try? data.decode("ec") | ||
self.decimalPlaces = try? data.decode("dp") | ||
} | ||
} | ||
} | ||
|
||
public struct AppEntityRegistryListForDisplay: Codable, FetchableRecord, PersistableRecord { | ||
/// serverId-entityId | ||
let id: String | ||
let serverId: String | ||
let entityId: String | ||
let registry: EntityRegistryListForDisplay.Entity | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters