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) { private TriggerAutosensValue(TriggerAutosensValue triggerAutosensValue) {
super(); super();
value = triggerAutosensValue.value; value = new InputDouble(triggerAutosensValue.value);
lastRun = triggerAutosensValue.lastRun; lastRun = triggerAutosensValue.lastRun;
comparator = new Comparator(triggerAutosensValue.comparator);
} }
public double getValue() { public double getValue() {
@ -67,12 +68,6 @@ public class TriggerAutosensValue extends Trigger {
if (lastRun > DateUtil.now() - T.mins(5).msecs()) if (lastRun > DateUtil.now() - T.mins(5).msecs())
return false; 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)); boolean doRun = comparator.getValue().check((autosensData.autosensResult.ratio), (double) (getValue() / 100d));
if (doRun) { if (doRun) {
if (L.isEnabled(L.AUTOMATION)) if (L.isEnabled(L.AUTOMATION))
@ -102,7 +97,7 @@ public class TriggerAutosensValue extends Trigger {
Trigger fromJSON(String data) { Trigger fromJSON(String data) {
try { try {
JSONObject d = new JSONObject(data); JSONObject d = new JSONObject(data);
value.setValue(JsonHelper.safeGetInt(d, "value")); value.setValue(JsonHelper.safeGetDouble(d, "value"));
lastRun = JsonHelper.safeGetLong(d, "lastRun"); lastRun = JsonHelper.safeGetLong(d, "lastRun");
comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator"))); comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator")));
} catch (Exception e) { } catch (Exception e) {