Files
iOS/Sources/Shared/EntityRegistryListForDisplay.swift
Bruno Pantaleão Gonçalves b3b3bd6ee9 Use correct sensor precision in sensors widget (#3269)
<!-- 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 -->
Pending on: https://github.com/home-assistant/iOS/pull/3268

CC: @Penait1 

## 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-12 17:51:26 +00:00

34 lines
1.0 KiB
Swift

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
public let registry: EntityRegistryListForDisplay.Entity
}