diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java index 64f1b0d9fd..2a055b24d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/Trigger.java @@ -100,9 +100,9 @@ public abstract class Trigger { static Trigger instantiate(JSONObject object) { try { String type = object.getString("type"); - String data = object.getString("data"); + JSONObject data = object.getJSONObject("data"); Class clazz = Class.forName(type); - return ((Trigger) clazz.newInstance()).fromJSON(data); + return ((Trigger) clazz.newInstance()).fromJSON(data.toString()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.java index fbad5deea1..3e2abd61a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBg.java @@ -66,7 +66,7 @@ public class TriggerBg extends Trigger { data.put("threshold", threshold); data.put("comparator", comparator.toString()); data.put("units", units); - o.put("data", data.toString()); + o.put("data", data); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java index 1abb0362c8..b4aa3d711b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerTime.java @@ -156,7 +156,7 @@ public class TriggerTime extends Trigger { data.put("minute", minute); data.put("validTo", validTo); object.put("type", TriggerTime.class.getName()); - object.put("data", data.toString()); + object.put("data", data); } catch (JSONException e) { e.printStackTrace(); }