 public class OpenHABItemCache {
     public static let instance = OpenHABItemCache()
 
+    public static let URL_NONE = 0
+    public static let URL_LOCAL = 1
+    public static let URL_REMOTE = 2
+    public static let URL_DEMO = 3
+
     public var items: [OpenHABItem]?
     public var url = ""
+    public var localUrlFailed = false
+    public var lastUrlConnected = URL_NONE
     public var lastLoad = NSDate().timeIntervalSince1970
 
     public func getItemNames(searchTerm: String?, types: [OpenHABItem.ItemType]?, completion: @escaping ([NSString]) -> Void) {

    func getURL() -> URL? {
        var uurl: URL?

        if url == "" {
            if Preferences.demomode {
                uurl = Endpoint.items(openHABRootUrl: "http://demo.openhab.org:8080").url
                url = uurl?.absoluteString ?? "unknown"

            } else {
                uurl = Endpoint.items(openHABRootUrl: Preferences.remoteUrl).url
                url = uurl?.absoluteString ?? "unknown"
            }

        } else {
            uurl = URL(string: url)
        }

        return uurl

                        os_log("%{PUBLIC}@ ", log: .default, type: .error, error.localizedDescription)
                    }
                }

            case let .failure(error):
                if self.lastUrlConnected == OpenHABItemCache.URL_LOCAL {
                    self.localUrlFailed = true
                    os_log("%{PUBLIC}@ ", log: .default, type: .info, error.localizedDescription)
                    self.reload(name: name, completion: completion) // try remote

                } else {
                    os_log("%{PUBLIC}@ ", log: .default, type: .error, error.localizedDescription)
                }
            }
        }
    }
