Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Spriter committed May 19, 2016
1 parent 721c702 commit 81951a5
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
7 changes: 7 additions & 0 deletions SwiftyHue/Classes/BridgeResourceModels/AppData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import Gloss

public struct AppData: Decodable, Encodable {

/**
App specific version of the data field. App should take versioning into account when parsing the data string.
*/
public let version: Int

/**
App specific data. Free format string.
*/
public let data: String

public init(version: Int, data: String) {
Expand Down
39 changes: 39 additions & 0 deletions SwiftyHue/Classes/BridgeResourceModels/Light.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,54 @@ public class Light: BridgeResource, BridgeResourceDictGenerator {

public typealias AssociatedBridgeResourceType = Light

/**
Identifier of the light.
*/
public let identifier: String

/**
A unique, editable name given to the light.
*/
public let name: String

/**
Details the state of the light.
*/
public let state: LightState

/**
A fixed name describing the type of light e.g. “Extended color light”.
*/
public let type: String

/**
The hardware model of the light.
*/
public let modelId: String

/**
As of 1.4. Unique id of the device. The MAC address of the device with a unique endpoint id in the form: AA:BB:CC:DD:EE:FF:00:11-XX
*/
public let uniqueId: String

/**
As of 1.7. The manufacturer name.
*/
public let manufacturerName: String

/**
As of 1.9. Unique ID of the luminaire the light is a part of in the format: AA:BB:CC:DD-XX-YY. AA:BB:, ... represents the hex of the luminaireid, XX the lightsource position (incremental but may contain gaps) and YY the lightpoint position (index of light in luminaire group). A gap in the lightpoint position indicates an incomplete luminaire (light search required to discover missing light points in this case).
*/
public let luminaireUniqueId: String?

/**
An identifier for the software version running on the light.
*/
public let swVersion: String

/**
This parameter is reserved for future functionality. As from 1.11 point symbols are no longer returned.
*/
public let pointsymbol: String?

public required init?(json: JSON) {
Expand Down
41 changes: 37 additions & 4 deletions SwiftyHue/Classes/BridgeResourceModels/Scene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,51 @@ public class PartialScene: BridgeResource, BridgeResourceDictGenerator {

public typealias AssociatedBridgeResourceType = PartialScene

/**
The identifier of this scene.
*/
public let identifier: String

/**
The name of this scene.
*/
public let name: String

/**
The identifiers of the lights controlled by this scene.
*/
public let lightIdentifiers: [String]

/**
Whitelist user that created or modified the content of the scene. Note that changing name does not change the owner..
*/
public let owner: String

/**
Indicates whether the scene can be automatically deleted by the bridge. Only available by POSTSet to 'false' when omitted. Legacy scenes created by PUT are defaulted to true. When set to 'false' the bridge keeps the scene until deleted by an application.
*/
public let recycle: Bool

/**
Indicates that the scene is locked by a rule or a schedule and cannot be deleted until all resources requiring or that reference the scene are deleted.
*/
public let locked: Bool

/**
App specific data linked to the scene. Each individual application should take responsibility for the data written in this field.
*/
public let appData: AppData?
public let picture: String?

/**
UTC time the scene has been created or has been updated by a PUT. Will be null when unknown (legacy scenes).
*/
public let lastUpdated: NSDate?

/**
Version of scene document:
1 - Scene created via PUT, lightstates will be empty.
2 - Scene created via POST lightstates available.
*/
public let version: Int

public required init?(json: JSON) {
Expand All @@ -69,7 +105,6 @@ public class PartialScene: BridgeResource, BridgeResourceDictGenerator {
let dateFormatter = NSDateFormatter.hueApiDateFormatter

self.appData = "appdata" <~~ json
picture = "picture" <~~ json
lastUpdated = Decoder.decodeDate("lastupdated", dateFormatter:dateFormatter)(json)
}

Expand All @@ -85,7 +120,6 @@ public class PartialScene: BridgeResource, BridgeResourceDictGenerator {
"recycle" ~~> self.recycle,
"locked" ~~> self.locked,
"appdata" ~~> self.appData,
"picture" ~~> self.picture,
"lastupdated" ~~> Encoder.encodeDate("lastupdated", dateFormatter: dateFormatter)(self.lastUpdated),
"version" ~~> self.version
])
Expand All @@ -111,7 +145,6 @@ public func ==(lhs: PartialScene, rhs: PartialScene) -> Bool {
lhs.recycle == rhs.recycle &&
lhs.locked == rhs.locked &&
lhs.appData == rhs.appData &&
lhs.picture == rhs.picture &&
lhs.lastUpdated == rhs.lastUpdated &&
lhs.version == rhs.version
}
1 change: 1 addition & 0 deletions SwiftyHue/Classes/SwiftyHue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class SwiftyHue {

public init() {

enableLogging(false)
}
}

Expand Down

0 comments on commit 81951a5

Please sign in to comment.