-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade HAKit and use it for REST API calls
- Loading branch information
Showing
9 changed files
with
107 additions
and
218 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import Foundation | ||
import ObjectMapper | ||
import HAKit | ||
|
||
public struct LogbookEntry: ImmutableMappable { | ||
public let entityId: String | ||
public struct LogbookEntry: HADataDecodable { | ||
public let entityId: String? | ||
public let when: Date | ||
public let domain: String? | ||
public let message: String? | ||
public let state: String? | ||
public let name: String? | ||
public let iconName: String? | ||
|
||
public init(map: Map) throws { | ||
self.entityId = try map.value("entity_id") | ||
self.when = try map.value("when", using: HomeAssistantTimestampTransform()) | ||
self.domain = try? map.value("domain") | ||
self.message = try? map.value("message") | ||
self.state = try? map.value("state") | ||
self.name = try? map.value("name") | ||
self.iconName = try? map.value("icon") | ||
public init(data: HAData) throws { | ||
self.when = try data.decode("when") | ||
self.entityId = data.decode("entity_id", fallback: nil) | ||
self.domain = data.decode("domain", fallback: nil) | ||
self.message = data.decode("message", fallback: nil) | ||
self.state = data.decode("state", fallback: nil) | ||
self.name = data.decode("name", fallback: nil) | ||
self.iconName = data.decode("icon", fallback: nil) | ||
} | ||
} |
Oops, something went wrong.