/*
   * Obtain device names configured in the WebUI (ReGa)
   */
  private static void fetchDeviceNamesFromReGa() {
    lastFetch = System.currentTimeMillis();

    L.info("Obtaining ReGa device and channel names");
    String r =
        TCLRegaHandler.sendHMScript(
            "string id;"
                + "foreach(id, root.Channels ().EnumUsedIDs())"
                + "  {"
                + "   var ch=dom.GetObject(id);"
                + "   WriteLine(ch.Address()+\"\t\"+ch.Name());"
                + "  }"
                + "foreach(id, root.Devices().EnumUsedIDs())"
                + "  {"
                + "   var d=dom.GetObject(id);"
                + "   WriteLine(d.Address()+\":0\t\"+d.Name());"
                + "  }");
    if (r == null) return;
    String lines[] = r.split("\n");
    for (String l : lines) {
      String p[] = l.split("\t");
      synchronized (nameCache) {
        if (p.length == 2) nameCache.put(p[0], p[1]);
      }
    }
    couldFetchOnce = true;
    DeviceInfo.resolveNames();
  }
 /*
  * Obtain device names from a JSON table (e.g. from hm-manager)
  */
 private static void fetchDeviceNamesFromNameTable(String filename) {
   lastFetch = System.currentTimeMillis();
   try (FileReader f = new FileReader(filename)) {
     JsonObject table = Json.parse(f).asObject();
     int cnt = 0;
     synchronized (nameCache) {
       for (Member m : table) {
         nameCache.put(m.getName(), m.getValue().asString());
         cnt++;
       }
     }
     L.log(Level.INFO, "Read " + cnt + " entries from name table " + filename);
     couldFetchOnce = true;
     DeviceInfo.resolveNames();
   } catch (Exception e) {
     L.log(Level.WARNING, "Error reading device name table " + filename, e);
   }
 }
 public static String getNameForAddress(String address) {
   synchronized (nameCache) {
     return nameCache.get(address);
   }
 }