Skip to content

Commit

Permalink
Group ordering fix
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiet480 committed Jan 7, 2017
1 parent f91bbc0 commit 4b9bdb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion HomeAssistant/Classes/Components/GroupComponent.swift
Expand Up @@ -34,7 +34,7 @@ class Group: Entity {
IsAllGroup <- (map["entity_id"], isAllGroupTransform)
View <- map["attributes.view"]
Auto <- map["attributes.auto"]
Order.value <- map["attributes.order"]
Order.value <- map["attributes.order"]

EntityIds <- map["attributes.entity_id"]

Expand Down
8 changes: 7 additions & 1 deletion HomeAssistant/HAAPI.swift
Expand Up @@ -392,7 +392,13 @@ public class HomeAssistantAPI {
case is GarageDoor:
realm.create(GarageDoor.self, value: entity, update: true)
case is Group:
realm.create(Group.self, value: entity, update: true)
if let currentObject = realm.object(ofType: Group.self, forPrimaryKey: entity.ID as AnyObject) {
let group = entity as! Group
group.Order = currentObject.Order
realm.create(Group.self, value: entity, update: true)
} else {
realm.create(Group.self, value: entity, update: true)
}
case is Fan:
realm.create(Fan.self, value: entity, update: true)
case is InputBoolean:
Expand Down

0 comments on commit 4b9bdb7

Please sign in to comment.