private String resultToJSON(Object o) {
		String out = "";

		if (o == null) {
			out = "null"; // legacy with void returning methods in python
		} else if ((o instanceof List) || (o instanceof Vector)) {
			out += "[ ";
			Iterator it = ((List) o).iterator();
			boolean first = true;

			while (it.hasNext()) {
				if (!first) {
					out += ", ";
				} else {
					first = false;
				}
				Object e = it.next();

				out += this.resultToJSON(e);
			}
			out += " ]";
		} else if (o instanceof Enumeration) {
			out += "[ ";
			boolean first = true;

			Enumeration e = (Enumeration) o;

			while (e.hasMoreElements()) {
				if (!first) {
					out += ", ";
				} else {
					first = false;
				}

				out += this.resultToJSON(e);
			}
			out += " ]";
		} else if (o instanceof Hashtable) {
			Hashtable ht = (Hashtable) o;
			Enumeration keys = ht.keys();
			boolean first = true;
			out = "{ ";
			while (keys.hasMoreElements()) {
				if (first) {
					first = false;
				} else {
					out += ", ";
				}

				Object key = keys.nextElement();
				Object value = ht.get(key);

				if (value instanceof String) {
					out += "\"" + key.toString() + "\"" + ": " + "\"" + ht.get(key).toString() + "\"";
				} else {
					out += "\"" + key.toString() + "\": " + this.resultToJSON(value);
				}
			}

			out += " }";
		} else if (o instanceof String) {
			// log.debug("traduco " + o);
			out = "\"" + o.toString() + "\"";
		} else if (o instanceof Integer) {
			out = o.toString();
		} else if (o instanceof Double) {
			out = o.toString();
		} else if (o instanceof ICategory) {
			ICategory category = (ICategory) o;
			out = "{ \"name\": \"" + category.getName() + "\", \"icon\": \"" + category.getIconName() + "\" }";
		} else if (o instanceof ILocation) {
			ILocation location = (ILocation) o;
			// log.debug("traduco " + location.getName());
			out = "{ " + "\"name\": \"" + _(location.getName()) + "\", " + "\"icon\": \"" + location.getIconName() + "\", " + "\"pid\": \"" + location.getPid() + "\"" + "}";
		} else if (o instanceof IAppliance) {
			out += "\"" + ((IAppliance) o).getPid() + "\"";
		} else if (o instanceof IServiceCluster) {
			out += "\"" + ((IServiceCluster) o).getEndPoint().getAppliance().getPid() + "\"";
		} else if (o instanceof IAttributeValue) {
			IAttributeValue v = (IAttributeValue) o;
			Object value = v.getValue();
			if (value instanceof String)
				out += "{ \"type\": \"string\", \"value\": " + "\"" + value.toString() + "\" }";
			else
				out += "{ \"type\": \"double\", \"value\": " + value.toString() + " }";
		} else if (o instanceof byte[]) {
			out += "\"" + byteToHex((byte[]) o) + "\"";
		} else if (o.getClass().isArray()) {
			Object[] o1 = (Object[]) o;

			out += "[ ";
			boolean first = true;

			for (int i = 0; i < o1.length; i++) {
				if (!first) {
					out += ", ";
				} else {
					first = false;
				}
				out += this.resultToJSON(o1[i]);
			}
			out += " ]";
		} else {
			out = "\"" + o.toString() + "\"";
		}
		return out;
	}
  public FunctionData getMatchingPropertyValue(
      String attributeName, IAttributeValue attributeValue) {

    FunctionData data = null;
    if (ApplianceControlServer.ATTR_TemperatureTarget0_NAME.equals(attributeName)) {
      int value = (Integer) (attributeValue.getValue());
      data =
          new LevelData(
              attributeValue.getTimestamp(), null, Units.DEGREE_CELSIUS, new BigDecimal(value));
    } else if (ApplianceControlServer.ATTR_CycleTarget0_NAME.equals(attributeName)) {
      Short v = (Short) (attributeValue.getValue());
      data = new LevelData(attributeValue.getTimestamp(), null, CYCLEUNIT, new BigDecimal(v));
    } else if (ApplianceControlServer.ATTR_Spin_NAME.equals(attributeName)) {
      Short v2 = (Short) (attributeValue.getValue());
      data = new LevelData(attributeValue.getTimestamp(), null, SPINUNIT, new BigDecimal(v2));
    } else if (ApplianceControlServer.ATTR_StartTime_NAME.equals(attributeName)) {
      TimeAttribute t = DataConverters.toTimeAttribute((Integer) attributeValue.getValue());
      data = new TimeData(attributeValue.getTimestamp(), null, t);
    } else if (ApplianceControlServer.ATTR_FinishTime_NAME.equals(attributeName)) {
      TimeAttribute t2 = DataConverters.toTimeAttribute((Integer) attributeValue.getValue());
      data = new TimeData(attributeValue.getTimestamp(), null, t2);
    } else if (ApplianceControlServer.ATTR_RemainingTime_NAME.equals(attributeName)) {
      TimeAttribute t3 = DataConverters.toTimeAttribute((Integer) attributeValue.getValue());
      data = new TimeData(attributeValue.getTimestamp(), null, t3);
    } else {

      return null;
    }

    return data;
  }