mirror of
https://github.com/home-assistant/iOS.git
synced 2026-02-09 18:33:16 -06:00
28 lines
748 B
Swift
28 lines
748 B
Swift
import Foundation
|
|
import PromiseKit
|
|
|
|
public class LastUpdateSensor: SensorProvider {
|
|
public let request: SensorProviderRequest
|
|
public required init(request: SensorProviderRequest) {
|
|
self.request = request
|
|
}
|
|
|
|
public func sensors() -> Promise<[WebhookSensor]> {
|
|
let icon: String
|
|
|
|
if Current.isCatalyst {
|
|
// Use laptop icon for all Macs
|
|
icon = "mdi:laptop"
|
|
} else {
|
|
icon = "mdi:cellphone-wireless"
|
|
}
|
|
|
|
return .value([
|
|
with(WebhookSensor(name: "Last Update Trigger", uniqueID: WebhookSensorId.lastUpdateTrigger.rawValue)) {
|
|
$0.Icon = icon
|
|
$0.State = request.lastUpdateReason
|
|
},
|
|
])
|
|
}
|
|
}
|