mirror of
https://github.com/home-assistant/iOS.git
synced 2026-04-12 05:08:23 -05:00
<!-- 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. --> <img width="800" height="480" alt="Simulator Screenshot - Daily tester 2 - 2026-03-31 at 16 45 28" src="https://github.com/user-attachments/assets/927764c8-9de7-49e9-98c4-8cc8fd0bcf6b" /> ## 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. -->
57 lines
1.4 KiB
Swift
57 lines
1.4 KiB
Swift
import Foundation
|
|
import GRDB
|
|
import HAKit
|
|
|
|
public struct AppArea: Codable, FetchableRecord, PersistableRecord {
|
|
/// serverId-areaId
|
|
public let id: String
|
|
public let serverId: String
|
|
public let areaId: String
|
|
public let name: String
|
|
public let aliases: [String]
|
|
public let picture: String?
|
|
public let icon: String?
|
|
public let sortOrder: Int?
|
|
/// Array containing entity Ids that belong to area
|
|
public let entities: Set<String>
|
|
|
|
public init(
|
|
id: String,
|
|
serverId: String,
|
|
areaId: String,
|
|
name: String,
|
|
aliases: [String],
|
|
picture: String?,
|
|
icon: String?,
|
|
sortOrder: Int?,
|
|
entities: Set<String>
|
|
) {
|
|
self.id = id
|
|
self.serverId = serverId
|
|
self.areaId = areaId
|
|
self.name = name
|
|
self.aliases = aliases
|
|
self.picture = picture
|
|
self.icon = icon
|
|
self.sortOrder = sortOrder
|
|
self.entities = entities
|
|
}
|
|
|
|
public init(
|
|
from area: HAAreasRegistryResponse,
|
|
serverId: String,
|
|
entities: Set<String>?,
|
|
sortOrder: Int?
|
|
) {
|
|
self.id = "\(serverId)-\(area.areaId)"
|
|
self.serverId = serverId
|
|
self.areaId = area.areaId
|
|
self.name = area.name
|
|
self.aliases = area.aliases
|
|
self.picture = area.picture
|
|
self.icon = area.icon
|
|
self.sortOrder = sortOrder
|
|
self.entities = entities ?? []
|
|
}
|
|
}
|