Fixing after comments

This commit is contained in:
Roumen Georgiev 2019-05-23 10:59:28 +03:00 committed by GitHub
parent 27eb11e5df
commit af739a3b66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,8 +43,9 @@ public class TriggerAutosensValue extends Trigger {
private TriggerAutosensValue(TriggerAutosensValue triggerAutosensValue) {
super();
value = triggerAutosensValue.value;
value = new InputDouble(triggerAutosensValue.value);
lastRun = triggerAutosensValue.lastRun;
comparator = new Comparator(triggerAutosensValue.comparator);
}
public double getValue() {
@ -67,12 +68,6 @@ public class TriggerAutosensValue extends Trigger {
if (lastRun > DateUtil.now() - T.mins(5).msecs())
return false;
if (autosensData.autosensResult.ratio != 0 && comparator.getValue() == Comparator.Compare.IS_NOT_AVAILABLE) {
if (L.isEnabled(L.AUTOMATION))
log.debug("Ready for execution: " + friendlyDescription());
return true;
}
boolean doRun = comparator.getValue().check((autosensData.autosensResult.ratio), (double) (getValue() / 100d));
if (doRun) {
if (L.isEnabled(L.AUTOMATION))
@ -102,7 +97,7 @@ public class TriggerAutosensValue extends Trigger {
Trigger fromJSON(String data) {
try {
JSONObject d = new JSONObject(data);
value.setValue(JsonHelper.safeGetInt(d, "value"));
value.setValue(JsonHelper.safeGetDouble(d, "value"));
lastRun = JsonHelper.safeGetLong(d, "lastRun");
comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator")));
} catch (Exception e) {
@ -154,4 +149,4 @@ public class TriggerAutosensValue extends Trigger {
.add(new LabelWithElement(MainApp.gs(R.string.autosenslabel) + ": ", "", value))
.build(root);
}
}
}