Add a rules engine so I can be notified when I forget to close my garage door.

This commit is contained in:
MarkBryanMilligan
2021-07-15 23:34:15 -05:00
parent de50645a2c
commit 3d5cd6500f
81 changed files with 2044 additions and 231 deletions

View File

@@ -154,6 +154,14 @@ public class Switch {
return type == SwitchType.RELAY;
}
public boolean isRelayButton() {
return type == SwitchType.RELAY_BUTTON;
}
public boolean isSecurity() {
return type == SwitchType.SECURITY;
}
public boolean isControlledBy(String _controllerUrl) {
return NullUtils.isEqual(_controllerUrl, controllerUrl);
}

View File

@@ -7,5 +7,6 @@ public enum SwitchType {
SPACE_HEATER_THERMOSTAT,
THERMOMETER,
RELAY,
SECURITY
SECURITY,
RELAY_BUTTON
}

View File

@@ -13,6 +13,7 @@ public class ZWaveConfig {
private String commPort;
private String url;
private String masterUrl;
private String rulesUrl;
private List<Switch> switches;
public int getAccountId() {
@@ -47,6 +48,14 @@ public class ZWaveConfig {
masterUrl = _masterUrl;
}
public String getRulesUrl() {
return rulesUrl;
}
public void setRulesUrl(String _rulesUrl) {
rulesUrl = _rulesUrl;
}
public List<Switch> getSwitches() {
return switches;
}

View File

@@ -36,11 +36,11 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
d.put("gpio_pin", _o.getGpioPin());
d.put("primary", _o.isPrimary());
d.put("hold", _o.isHold());
d.put("hidden", _o.isHidden());
d.put("thermometer_url", _o.getThermometerUrl());
d.put("controller_url", _o.getControllerUrl());
d.put("thermostat_mode", DaoSerializer.toEnumName(_o.getThermostatMode()));
d.put("low_level", _o.getLowLevel());
d.put("hidden", _o.isHidden());
d.put("schedule", DaoSerializer.toDaoEntities(_o.getSchedule(), DaoProxyType.MONGO));
return d;
}
@@ -57,11 +57,11 @@ public class SwitchSerializer extends AbstractDaoSerializer<Switch>
o.setGpioPin(DaoSerializer.getInteger(_d, "gpio_pin"));
o.setPrimary(DaoSerializer.getBoolean(_d, "primary"));
o.setHold(DaoSerializer.getBoolean(_d, "hold"));
o.setHidden(DaoSerializer.getBoolean(_d, "hidden"));
o.setThermometerUrl(DaoSerializer.getString(_d, "thermometer_url"));
o.setControllerUrl(DaoSerializer.getString(_d, "controller_url"));
o.setThermostatMode(DaoSerializer.getEnum(_d, "thermostat_mode", ThermostatMode.class));
o.setLowLevel(DaoSerializer.getInteger(_d, "low_level"));
o.setHidden(DaoSerializer.getBoolean(_d, "hidden"));
o.setSchedule(DaoSerializer.getList(_d, "schedule", SwitchSchedule.class));
return o;
}

View File

@@ -31,6 +31,7 @@ public class ZWaveConfigSerializer extends AbstractDaoSerializer<ZWaveConfig>
d.put("comm_port", _o.getCommPort());
d.put("url", _o.getUrl());
d.put("master_url", _o.getMasterUrl());
d.put("rules_url", _o.getRulesUrl());
d.put("switches", DaoSerializer.toDaoEntities(_o.getSwitches(), DaoProxyType.MONGO));
return d;
}
@@ -43,6 +44,7 @@ public class ZWaveConfigSerializer extends AbstractDaoSerializer<ZWaveConfig>
o.setCommPort(DaoSerializer.getString(_d, "comm_port"));
o.setUrl(DaoSerializer.getString(_d, "url"));
o.setMasterUrl(DaoSerializer.getString(_d, "master_url"));
o.setRulesUrl(DaoSerializer.getString(_d, "rules_url"));
o.setSwitches(DaoSerializer.getList(_d, "switches", Switch.class));
return o;
}