diff --git a/HomeAssistant/Classes/Components/GroupComponent.swift b/HomeAssistant/Classes/Components/GroupComponent.swift index 9edd95780..f95b0c8f9 100644 --- a/HomeAssistant/Classes/Components/GroupComponent.swift +++ b/HomeAssistant/Classes/Components/GroupComponent.swift @@ -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"] diff --git a/HomeAssistant/HAAPI.swift b/HomeAssistant/HAAPI.swift index b4493406b..57180a687 100644 --- a/HomeAssistant/HAAPI.swift +++ b/HomeAssistant/HAAPI.swift @@ -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: